oauth2

package
v0.15.11 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 19, 2024 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ResponseTypeCode  = "code"
	ResponseTypeToken = "token"
)
View Source
const (
	GrantAuthorizationCode = "authorization_code"
	GrantClientCredentials = "client_credentials"
	GrantRefreshToken      = "refresh_token"
)

Variables

This section is empty.

Functions

func NewFactory

func NewFactory() auth.IAuthFactory

NewFactory 生成一个 auth_apiKey工厂

func Register

func Register()

Register 注册auth驱动工厂

func Scan

func Scan(src []interface{}, dest ...interface{}) ([]interface{}, error)

Scan copies from src to the values pointed at by dest.

Scan uses RedisScan if available otherwise:

The values pointed at by dest must be an integer, float, boolean, string, []byte, interface{} or slices of these types. Scan uses the standard strconv package to convert bulk strings to numeric and boolean types.

If a dest value is nil, then the corresponding src value is skipped.

If a src element is nil, then the corresponding dest value is not modified.

To enable easy use of Scan in a loop, Scan returns the slice of src following the copied values.

Types

type AuthorizeHandler

type AuthorizeHandler struct {
	// contains filtered or unexported fields
}

func NewAuthorizeHandler

func NewAuthorizeHandler() *AuthorizeHandler

func (*AuthorizeHandler) Handle

func (a *AuthorizeHandler) Handle(ctx http_context.IHttpContext, client *Client, params url.Values)

type Client

type Client struct {
	*Pattern
	// Expire 过期时间
	Expire int64
	// contains filtered or unexported fields
}

type Config

type Config struct {
	application.Auth
	Users []*User `json:"users" label:"用户列表"`
}

type Error

type Error string

func (Error) Error

func (err Error) Error() string

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

func NewHandler

func NewHandler(handler IHandler) *Handler

func (*Handler) Server

func (h *Handler) Server(eoContext eoscContext.EoContext) (isContinue bool)

type IHandler

type IHandler interface {
	Handle(ctx http_context.IHttpContext, client *Client, params url.Values)
}

type Manager

type Manager struct {
	// contains filtered or unexported fields
}

Manager 管理oauth2配置

func NewManager

func NewManager() *Manager

type Pattern

type Pattern struct {
	ClientId                      string   `json:"client_id"`
	ClientSecret                  string   `json:"client_secret"`
	ClientType                    string   `json:"client_type"`
	HashSecret                    bool     `json:"hash_secret"`
	RedirectUrls                  []string `json:"redirect_urls" label:"重定向URL"`
	Scopes                        []string `json:"scopes" label:"授权范围"`
	MandatoryScope                bool     `json:"mandatory_scope" label:"强制授权"`
	ProvisionKey                  string   `json:"provision_key" label:"Provision Key"`
	TokenExpiration               int      `json:"token_expiration" label:"令牌过期时间"`
	RefreshTokenTTL               int      `json:"refresh_token_ttl" label:"刷新令牌TTL"`
	EnableAuthorizationCode       bool     `json:"enable_authorization_code"  label:"启用授权码模式"`
	EnableImplicitGrant           bool     `json:"enable_implicit_grant" label:"启用隐式授权模式"`
	EnableClientCredentials       bool     `json:"enable_client_credentials" label:"启用客户端凭证模式"`
	AcceptHttpIfAlreadyTerminated bool     `json:"accept_http_if_already_terminated" label:"如果已终止,则接受HTTP"`
	ReuseRefreshToken             bool     `json:"reuse_refresh_token" label:"重用刷新令牌"`
	PersistentRefreshToken        bool     `json:"persistent_refresh_token" label:"持久刷新令牌"`
}

type Scanner

type Scanner interface {
	// RedisScan assigns a value from a Redis value. The argument src is one of
	// the reply types listed in the section `Executing Commands`.
	//
	// An error should be returned if the value cannot be stored without
	// loss of information.
	RedisScan(src interface{}) error
}

type Token

type Token struct {
	TokenType    string `json:"token_type"`
	ExpiresIn    int    `json:"expires_in"`
	AccessToken  string `json:"access_token,omitempty"`
	RefreshToken string `json:"refresh_token,omitempty"`
	Scope        string `json:"scope,omitempty"`
}

type TokenData

type TokenData struct {
	AuthenticatedUserid interface{} `json:"authenticated_userid"`
	Credential          struct {
		Id string `json:"id"`
	} `json:"credential"`
	AccessToken  string      `json:"access_token"`
	Service      interface{} `json:"service"`
	CreatedAt    int64       `json:"created_at"`
	RefreshToken interface{} `json:"refresh_token"`
	Scope        interface{} `json:"scope"`
	Ttl          int         `json:"ttl"`
	TokenType    string      `json:"token_type"`
	ExpiresIn    int         `json:"expires_in"`
	ClientID     string      `json:"client_id"`
}

type TokenHandler

type TokenHandler struct {
	// contains filtered or unexported fields
}

func NewTokenHandler

func NewTokenHandler() *TokenHandler

func (*TokenHandler) Handle

func (t *TokenHandler) Handle(ctx http_service.IHttpContext, client *Client, params url.Values)

func (*TokenHandler) ServeHTTP

func (t *TokenHandler) ServeHTTP(writer http.ResponseWriter, request *http.Request)

type TokenResponse

type TokenResponse struct {
	Total int          `json:"total"`
	Data  []*TokenData `json:"data"`
}

type User

type User struct {
	Pattern Pattern `json:"pattern" label:"用户信息"`
	application.User
}

func (*User) Username

func (u *User) Username() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL