Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AccessGenerate ¶
type AccessGenerate interface {
Token(ctx context.Context, data *GenerateBasic, isGenRefresh bool) (access, refresh string, err error)
}
AccessGenerate generate the access and refresh tokens interface
type AuthorizeGenerate ¶
type AuthorizeGenerate interface {
Token(ctx context.Context, data *GenerateBasic) (code string, err error)
}
AuthorizeGenerate generate the authorization code interface
type ClientInfo ¶
type ClientInfo interface { GetID() string GetSecret() string GetDomain() string IsPublic() bool GetUserID() string }
ClientInfo the client information model interface
type ClientPasswordVerifier ¶
ClientPasswordVerifier the password handler interface
type ClientStore ¶
type ClientStore interface { // according to the ID for the client information GetByID(ctx context.Context, id string) (ClientInfo, error) // NOTE // Remove a client if needed RemoveByID(id string) (err error) // NOTE // Add or update a client jwt(specific to svc clients) UpsertClientJWToken(ctx context.Context, id, JWToken string) (err error) }
ClientStore the client information storage interface
type CodeChallengeMethod ¶
type CodeChallengeMethod string
CodeChallengeMethod PCKE method
const ( // CodeChallengePlain PCKE Method CodeChallengePlain CodeChallengeMethod = "plain" // CodeChallengeS256 PCKE Method CodeChallengeS256 CodeChallengeMethod = "S256" )
func (CodeChallengeMethod) String ¶
func (ccm CodeChallengeMethod) String() string
func (CodeChallengeMethod) Validate ¶
func (ccm CodeChallengeMethod) Validate(cc, ver string) bool
Validate code challenge
type GenerateBasic ¶
type GenerateBasic struct { Client ClientInfo UserID string CreateAt time.Time TokenInfo TokenInfo Request *http.Request }
GenerateBasic provide the basis of the generated token data
type GrantType ¶
type GrantType string
GrantType authorization model
type JWTAccessGenerate ¶
type JWTAccessGenerate interface { CreateJWTAccessGenerate(kid string, key []byte, meth ...string) JWTAccessGenerate GenerateOpenidJWToken(ctx context.Context, tokenInfo TokenInfo, isGenRefresh bool, openidInfo OpenidInfo) (string, string, error) ValidOpenidJWToken(ctx context.Context, tokenSecret string) error GetdataOpenidJWToken(ctx context.Context, tokenSecret string) (map[string]interface{}, error) GetdataAdminOpenidJWToken(ctx context.Context, tokenSecret string) (map[string]interface{}, error) // GetTokensOpenidJWToken(ctx context.Context, tokenSecret string) (error, map[string]interface{}) // GetOauthTokensFromOpenidJWToken(ctx context.Context, tokenSecret string) (OpenidInfo, string, string, error) Token(ctx context.Context, data *GenerateBasic, isGenRefresh bool) (string, string, error) }
type Manager ¶
type Manager interface { // get the client information GetClient(ctx context.Context, clientID string) (cli ClientInfo, err error) // generate the authorization token(code) GenerateAuthToken(ctx context.Context, rt ResponseType, tgr *TokenGenerateRequest) (authToken TokenInfo, err error) // generate the access token GenerateAccessToken(ctx context.Context, gt GrantType, tgr *TokenGenerateRequest) (accessToken TokenInfo, err error) // refreshing an access token RefreshAccessToken(ctx context.Context, tgr *TokenGenerateRequest) (accessToken TokenInfo, err error) // use the access token to delete the token information RemoveAccessToken(ctx context.Context, access string) (err error) // use the refresh token to delete the token information RemoveRefreshToken(ctx context.Context, refresh string) (err error) // according to the access token for corresponding token information LoadAccessToken(ctx context.Context, access string) (ti TokenInfo, err error) // according to the refresh token for corresponding token information LoadRefreshToken(ctx context.Context, refresh string) (ti TokenInfo, err error) CreateJWTAccessGenerate(keyID string, secretKey []byte, signInMethod ...string) JWTAccessGenerate DeleteAuthorizationCode(ctx context.Context, code string) error // RefreshTokens refresh access and refresh JWT tokens RefreshTokens(ctx context.Context, refresh string) (TokenInfo, error) // use the access token to delete all the tokens information RemoveAllTokensByAccessToken(ctx context.Context, access string) (err error) // use the refresh token to delete all the tokens information RemoveAllTokensByRefreshToken(ctx context.Context, refresh string) (err error) // UpsertJWTClient upsert a jwtoken to the client UpsertClientJWToken(ctx context.Context, id, JWToken string) error }
Manager authorization management interface
type OpenidInfo ¶
type OpenidInfo map[string]interface{}
type ResponseType ¶
type ResponseType string
ResponseType the type of authorization request
const ( Code ResponseType = "code" Token ResponseType = "token" )
define the type of authorization request
func (ResponseType) String ¶
func (rt ResponseType) String() string
type TokenGenerateRequest ¶
type TokenGenerateRequest struct { ClientID string ClientSecret string UserID string RedirectURI string Scope string Role string Code string CodeChallenge string CodeChallengeMethod CodeChallengeMethod Refresh string CodeVerifier string AccessTokenExp time.Duration Request *http.Request }
TokenGenerateRequest provide to generate the token request parameters
type TokenInfo ¶
type TokenInfo interface { New() TokenInfo GetClientID() string SetClientID(string) GetUserID() string SetUserID(string) GetRedirectURI() string SetRedirectURI(string) GetScope() string SetScope(string) GetCode() string SetCode(string) GetCodeCreateAt() time.Time SetCodeCreateAt(time.Time) GetCodeExpiresIn() time.Duration SetCodeExpiresIn(time.Duration) GetCodeChallenge() string SetCodeChallenge(string) GetCodeChallengeMethod() CodeChallengeMethod SetCodeChallengeMethod(CodeChallengeMethod) // SetRole(string) GetRole() string GetAccess() string SetAccess(string) GetAccessCreateAt() time.Time SetAccessCreateAt(time.Time) GetAccessExpiresIn() time.Duration SetAccessExpiresIn(time.Duration) GetRefresh() string SetRefresh(string) GetRefreshCreateAt() time.Time SetRefreshCreateAt(time.Time) GetRefreshExpiresIn() time.Duration SetRefreshExpiresIn(time.Duration) }
TokenInfo the token information model interface
type TokenStore ¶
type TokenStore interface { // create and store the new token information Create(ctx context.Context, info TokenInfo) error // delete the authorization code RemoveByCode(ctx context.Context, code string) error // use the access token to delete the token information RemoveByAccess(ctx context.Context, access string) error // use the refresh token to delete the token information RemoveByRefresh(ctx context.Context, refresh string) error // NOTE // use the access token to delete all the tokens RemoveAllTokensByAccess(ctx context.Context, access string) error // NOTE // use the refresh token to delete all the tokens RemoveAllTokensByRefresh(ctx context.Context, refresh string) error // use the authorization code for token information data GetByCode(ctx context.Context, code string) (TokenInfo, error) // use the access token for token information data GetByAccess(ctx context.Context, access string) (TokenInfo, error) // use the refresh token for token information data GetByRefresh(ctx context.Context, refresh string) (TokenInfo, error) }
TokenStore the token information storage interface