Documentation ¶
Index ¶
- Constants
- func ConvertToOAuthUserAuthentication(userAuth security.Authentication, options ...ConvertOption) oauth2.UserAuthentication
- func IsSubSet(_ context.Context, superset utils.StringSet, subset utils.StringSet) (ok bool, invalid string)
- func LoadAndValidateClientId(c context.Context, clientId string, clientStore oauth2.OAuth2ClientStore) (oauth2.OAuth2Client, error)
- func NewJwtTokenStore(opts ...JTSOptions) *jwtTokenStore
- func NewWildcardUrlMatcher(pattern string) (*wildcardUrlMatcher, error)
- func ResolveRedirectUri(_ context.Context, redirectUri string, client oauth2.OAuth2Client) (string, error)
- func RetrieveAuthenticatedClient(c context.Context) oauth2.OAuth2Client
- func RetrieveFullyAuthenticatedClient(c context.Context) (oauth2.OAuth2Client, error)
- func ValidateAllAutoApprovalScopes(c context.Context, client oauth2.OAuth2Client, scopes utils.StringSet) error
- func ValidateAllScopes(c context.Context, client oauth2.OAuth2Client, scopes utils.StringSet) error
- func ValidateApproval(c context.Context, approval map[string]bool, client oauth2.OAuth2Client, ...) error
- func ValidateGrant(_ context.Context, client oauth2.OAuth2Client, grantType string) error
- func ValidateResponseTypes(ctx context.Context, request *AuthorizeRequest, supported utils.StringSet) error
- func ValidateScope(c context.Context, client oauth2.OAuth2Client, scopes ...string) error
- type AccessRevoker
- type AuthHandlerOption
- type AuthHandlerOptions
- type AuthorizationCodeStore
- type AuthorizationRegistry
- type AuthorizationService
- type AuthorizeHandler
- type AuthorizeRequest
- type AuthorizeRequestProcessChain
- type AuthorizeRequestProcessor
- type BasicClaimsTokenEnhancer
- type ChainedAuthorizeRequestProcessor
- type ClientDetails
- type CompositeTokenEnhancer
- type CompositeTokenGranter
- type ConvertOption
- type ConvertOptions
- type DASOption
- type DASOptions
- type DefaultAuthorizationService
- func (s *DefaultAuthorizationService) CreateAccessToken(c context.Context, oauth oauth2.Authentication) (oauth2.AccessToken, error)
- func (s *DefaultAuthorizationService) CreateAuthentication(ctx context.Context, request oauth2.OAuth2Request, ...) (oauth oauth2.Authentication, err error)
- func (s *DefaultAuthorizationService) RefreshAccessToken(c context.Context, oauth oauth2.Authentication, ...) (oauth2.AccessToken, error)
- func (s *DefaultAuthorizationService) SwitchAuthentication(ctx context.Context, request oauth2.OAuth2Request, ...) (oauth oauth2.Authentication, err error)
- type DefaultAuthorizeHandler
- func (h *DefaultAuthorizeHandler) Extend(makers ...AuthorizeHandler) *DefaultAuthorizeHandler
- func (h *DefaultAuthorizeHandler) HandleApprovalPage(ctx context.Context, r *AuthorizeRequest, user security.Authentication) (ResponseHandlerFunc, error)
- func (h *DefaultAuthorizeHandler) HandleApproved(ctx context.Context, r *AuthorizeRequest, user security.Authentication) (ResponseHandlerFunc, error)
- func (h *DefaultAuthorizeHandler) MakeAuthCodeResponse(ctx context.Context, r *AuthorizeRequest, user oauth2.UserAuthentication) (ResponseHandlerFunc, error)
- func (h *DefaultAuthorizeHandler) MakeImplicitResponse(ctx context.Context, r *AuthorizeRequest, user oauth2.UserAuthentication) (ResponseHandlerFunc, error)
- type DefaultOAuth2Client
- func (c *DefaultOAuth2Client) AccessTokenValidity() time.Duration
- func (c *DefaultOAuth2Client) AssignedTenantIds() utils.StringSet
- func (c *DefaultOAuth2Client) AutoApproveScopes() utils.StringSet
- func (c *DefaultOAuth2Client) CacheableCopy() security.Account
- func (c *DefaultOAuth2Client) ClientId() string
- func (c *DefaultOAuth2Client) Credentials() interface{}
- func (c *DefaultOAuth2Client) Disabled() bool
- func (c *DefaultOAuth2Client) GrantTypes() utils.StringSet
- func (c *DefaultOAuth2Client) ID() interface{}
- func (c *DefaultOAuth2Client) Locked() bool
- func (c *DefaultOAuth2Client) MaxTokensPerUser() int
- func (c *DefaultOAuth2Client) Permissions() []string
- func (c *DefaultOAuth2Client) RedirectUris() utils.StringSet
- func (c *DefaultOAuth2Client) RefreshTokenValidity() time.Duration
- func (c *DefaultOAuth2Client) ResourceIDs() utils.StringSet
- func (c *DefaultOAuth2Client) Scopes() utils.StringSet
- func (c *DefaultOAuth2Client) Secret() string
- func (c *DefaultOAuth2Client) SecretRequired() bool
- func (c *DefaultOAuth2Client) Type() security.AccountType
- func (c *DefaultOAuth2Client) UseMFA() bool
- func (c *DefaultOAuth2Client) UseSessionTimeout() bool
- func (c *DefaultOAuth2Client) Username() string
- type DetailsTokenEnhancer
- type ExpiryTokenEnhancer
- type JTSOption
- type JTSOptions
- type LegacyTokenEnhancer
- type OAuth2ClientAccountStore
- func (s *OAuth2ClientAccountStore) LoadAccountById(ctx context.Context, id interface{}) (security.Account, error)
- func (s *OAuth2ClientAccountStore) LoadAccountByUsername(ctx context.Context, username string) (security.Account, error)
- func (s *OAuth2ClientAccountStore) LoadLockingRules(ctx context.Context, acct security.Account) (security.AccountLockingRule, error)
- func (s *OAuth2ClientAccountStore) LoadPwdAgingRules(ctx context.Context, acct security.Account) (security.AccountPwdAgingRule, error)
- func (s *OAuth2ClientAccountStore) Save(ctx context.Context, acct security.Account) error
- type OAuth2ErrorHandler
- type OverrideAuthOptions
- type RedisAuthorizationCodeStore
- type RefreshTokenEnhancer
- type ResourceIdTokenEnhancer
- type ResponseHandlerFunc
- type RevokerTokenHint
- type StandardAuthorizeRequestProcessor
- type StdARPOption
- type StdARPOptions
- type TokenEnhancer
- type TokenGranter
- type TokenRequest
- type TokenStore
Constants ¶
const ( ApprovalModelKeyAuthRequest = "AuthRequest" ApprovalModelKeyApprovalUrl = "ApprovalUrl" )
const ( TokenEnhancerOrderExpiry TokenEnhancerOrderBasicClaims TokenEnhancerOrderDetailsClaims TokenEnhancerOrderResourceIdClaims TokenEnhancerOrderTokenDetails TokenEnhancerOrderRefreshToken )
Variables ¶
This section is empty.
Functions ¶
func ConvertToOAuthUserAuthentication ¶
func ConvertToOAuthUserAuthentication(userAuth security.Authentication, options ...ConvertOption) oauth2.UserAuthentication
ConvertToOAuthUserAuthentication takes any type of authentication and convert it into oauth2.Authentication
func LoadAndValidateClientId ¶
func LoadAndValidateClientId(c context.Context, clientId string, clientStore oauth2.OAuth2ClientStore) (oauth2.OAuth2Client, error)
func NewJwtTokenStore ¶
func NewJwtTokenStore(opts ...JTSOptions) *jwtTokenStore
func NewWildcardUrlMatcher ¶
NewWildcardUrlMatcher construct a wildcard URL matcher with given pattern The pattern should be escaped for URL endoding
func ResolveRedirectUri ¶
func RetrieveAuthenticatedClient ¶
func RetrieveAuthenticatedClient(c context.Context) oauth2.OAuth2Client
func RetrieveFullyAuthenticatedClient ¶
func RetrieveFullyAuthenticatedClient(c context.Context) (oauth2.OAuth2Client, error)
func ValidateAllScopes ¶
func ValidateApproval ¶
func ValidateApproval(c context.Context, approval map[string]bool, client oauth2.OAuth2Client, scopes utils.StringSet) error
ValidateApproval approval param is a map with scope as keys and approval status as values
func ValidateGrant ¶
func ValidateResponseTypes ¶
func ValidateScope ¶
Types ¶
type AccessRevoker ¶
type AccessRevoker interface { RevokeWithSessionId(ctx context.Context, sessionId string, sessionName string) error RevokeWithUsername(ctx context.Context, username string, revokeRefreshToken bool) error RevokeWithClientId(ctx context.Context, clientId string, revokeRefreshToken bool) error RevokeWithTokenValue(ctx context.Context, tokenValue string, hint RevokerTokenHint) error }
type AuthHandlerOption ¶
type AuthHandlerOption struct { Extensions []AuthorizeHandler ApprovalPageTmpl string ApprovalUrl string AuthService AuthorizationService AuthCodeStore AuthorizationCodeStore }
type AuthHandlerOptions ¶
type AuthHandlerOptions func(opt *AuthHandlerOption)
type AuthorizationCodeStore ¶
type AuthorizationCodeStore interface { GenerateAuthorizationCode(ctx context.Context, r *AuthorizeRequest, user security.Authentication) (string, error) ConsumeAuthorizationCode(ctx context.Context, authCode string, onetime bool) (oauth2.Authentication, error) }
type AuthorizationRegistry ¶
type AuthorizationRegistry interface { // Register RegisterRefreshToken(ctx context.Context, token oauth2.RefreshToken, oauth oauth2.Authentication) error RegisterAccessToken(ctx context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) error // Read ReadStoredAuthorization(ctx context.Context, token oauth2.RefreshToken) (oauth2.Authentication, error) FindSessionId(ctx context.Context, token oauth2.Token) (string, error) // Revoke RevokeRefreshToken(ctx context.Context, token oauth2.RefreshToken) error RevokeAccessToken(ctx context.Context, token oauth2.AccessToken) error RevokeAllAccessTokens(ctx context.Context, token oauth2.RefreshToken) error RevokeUserAccess(ctx context.Context, username string, revokeRefreshToken bool) error RevokeClientAccess(ctx context.Context, clientId string, revokeRefreshToken bool) error RevokeSessionAccess(ctx context.Context, sessionId string, revokeRefreshToken bool) error }
AuthorizationRegistry is responsible to keep track of refresh token and relationships between tokens, clients, users, sessions
type AuthorizationService ¶
type AuthorizationService interface { CreateAuthentication(ctx context.Context, request oauth2.OAuth2Request, userAuth security.Authentication) (oauth2.Authentication, error) SwitchAuthentication(ctx context.Context, request oauth2.OAuth2Request, userAuth security.Authentication, src oauth2.Authentication) (oauth2.Authentication, error) CreateAccessToken(ctx context.Context, oauth oauth2.Authentication) (oauth2.AccessToken, error) RefreshAccessToken(ctx context.Context, oauth oauth2.Authentication, refreshToken oauth2.RefreshToken) (oauth2.AccessToken, error) }
type AuthorizeHandler ¶
type AuthorizeHandler interface { // HandleApproved makes various ResponseHandlerFunc of authorization based on // - response_type // - scope // - other parameters // if the implementation decide to not to handle the AuthorizeRequest, returns nil, nil. // e.g. OIDC impl don't handle non OIDC request and don't handle "code" response type because it's identical from default oauth2 impl HandleApproved(ctx context.Context, r *AuthorizeRequest, user security.Authentication) (ResponseHandlerFunc, error) // HandleApprovalPage create ResponseHandlerFunc for user approval page HandleApprovalPage(ctx context.Context, r *AuthorizeRequest, user security.Authentication) (ResponseHandlerFunc, error) }
type AuthorizeRequest ¶
type AuthorizeRequest struct { Parameters map[string]string ClientId string ResponseTypes utils.StringSet Scopes utils.StringSet RedirectUri string State string Extensions map[string]interface{} Approved bool // contains filtered or unexported fields }
func NewAuthorizeRequest ¶
func NewAuthorizeRequest(opts ...func(req *AuthorizeRequest)) *AuthorizeRequest
func ParseAuthorizeRequest ¶
func ParseAuthorizeRequest(req *http.Request) (*AuthorizeRequest, error)
func ParseAuthorizeRequestWithKVs ¶
func ParseAuthorizeRequestWithKVs(ctx context.Context, values map[string]interface{}) (*AuthorizeRequest, error)
func (*AuthorizeRequest) Context ¶
func (r *AuthorizeRequest) Context() utils.MutableContext
func (*AuthorizeRequest) OAuth2Request ¶
func (r *AuthorizeRequest) OAuth2Request() oauth2.OAuth2Request
func (*AuthorizeRequest) String ¶
func (r *AuthorizeRequest) String() string
func (*AuthorizeRequest) WithContext ¶
func (r *AuthorizeRequest) WithContext(ctx context.Context) *AuthorizeRequest
type AuthorizeRequestProcessChain ¶
type AuthorizeRequestProcessChain interface {
Next(ctx context.Context, request *AuthorizeRequest) (processed *AuthorizeRequest, err error)
}
AuthorizeRequestProcessChain invoke index processor in the processing chain
type AuthorizeRequestProcessor ¶
type AuthorizeRequestProcessor interface {
Process(ctx context.Context, request *AuthorizeRequest) (processed *AuthorizeRequest, err error)
}
AuthorizeRequestProcessor validate and process incoming request AuthorizeRequestProcessor is the entry point interface for other components to use
func NewAuthorizeRequestProcessor ¶
func NewAuthorizeRequestProcessor(delegates ...ChainedAuthorizeRequestProcessor) AuthorizeRequestProcessor
type BasicClaimsTokenEnhancer ¶
type BasicClaimsTokenEnhancer struct {
// contains filtered or unexported fields
}
BasicClaimsTokenEnhancer impelments order.Ordered and TokenEnhancer
func (*BasicClaimsTokenEnhancer) Enhance ¶
func (te *BasicClaimsTokenEnhancer) Enhance(_ context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error)
func (*BasicClaimsTokenEnhancer) Order ¶
func (te *BasicClaimsTokenEnhancer) Order() int
type ChainedAuthorizeRequestProcessor ¶
type ChainedAuthorizeRequestProcessor interface {
Process(ctx context.Context, request *AuthorizeRequest, chain AuthorizeRequestProcessChain) (validated *AuthorizeRequest, err error)
}
ChainedAuthorizeRequestProcessor validate and process incoming request and manually invoke index processor in the chain.
type ClientDetails ¶
type ClientDetails struct { ClientId string Secret string GrantTypes utils.StringSet RedirectUris utils.StringSet Scopes utils.StringSet AutoApproveScopes utils.StringSet AccessTokenValidity time.Duration RefreshTokenValidity time.Duration UseSessionTimeout bool AssignedTenantIds utils.StringSet ResourceIds utils.StringSet }
type CompositeTokenEnhancer ¶
type CompositeTokenEnhancer struct {
// contains filtered or unexported fields
}
func NewCompositeTokenEnhancer ¶
func NewCompositeTokenEnhancer(delegates ...TokenEnhancer) *CompositeTokenEnhancer
func (*CompositeTokenEnhancer) Add ¶
func (e *CompositeTokenEnhancer) Add(enhancers ...TokenEnhancer)
func (*CompositeTokenEnhancer) Enhance ¶
func (e *CompositeTokenEnhancer) Enhance(ctx context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error)
func (*CompositeTokenEnhancer) Remove ¶
func (e *CompositeTokenEnhancer) Remove(enhancer TokenEnhancer)
type CompositeTokenGranter ¶
type CompositeTokenGranter struct {
// contains filtered or unexported fields
}
CompositeTokenGranter implements TokenGranter
func NewCompositeTokenGranter ¶
func NewCompositeTokenGranter(delegates ...TokenGranter) *CompositeTokenGranter
func (*CompositeTokenGranter) Add ¶
func (g *CompositeTokenGranter) Add(granter TokenGranter) *CompositeTokenGranter
func (*CompositeTokenGranter) Delegates ¶
func (g *CompositeTokenGranter) Delegates() []TokenGranter
func (*CompositeTokenGranter) Grant ¶
func (g *CompositeTokenGranter) Grant(ctx context.Context, request *TokenRequest) (oauth2.AccessToken, error)
type ConvertOption ¶
type ConvertOption func(option *ConvertOptions)
func ConvertWithSkipTypeCheck ¶
func ConvertWithSkipTypeCheck(skipTypeCheck bool) ConvertOption
type ConvertOptions ¶
type ConvertOptions struct { SkipTypeCheck bool // contains filtered or unexported fields }
func (*ConvertOptions) AppendUserAuthOptions ¶
func (c *ConvertOptions) AppendUserAuthOptions(option OverrideAuthOptions)
type DASOption ¶
type DASOption struct { DetailsFactory *common.ContextDetailsFactory ClientStore oauth2.OAuth2ClientStore AccountStore security.AccountStore TenantStore security.TenantStore ProviderStore security.ProviderStore Issuer security.Issuer TokenStore TokenStore TokenEnhancers []TokenEnhancer PostTokenEnhancers []TokenEnhancer }
type DASOptions ¶
type DASOptions func(*DASOption)
type DefaultAuthorizationService ¶
type DefaultAuthorizationService struct {
// contains filtered or unexported fields
}
DefaultAuthorizationService implements AuthorizationService
func NewDefaultAuthorizationService ¶
func NewDefaultAuthorizationService(opts ...DASOptions) *DefaultAuthorizationService
func (*DefaultAuthorizationService) CreateAccessToken ¶
func (s *DefaultAuthorizationService) CreateAccessToken(c context.Context, oauth oauth2.Authentication) (oauth2.AccessToken, error)
func (*DefaultAuthorizationService) CreateAuthentication ¶
func (s *DefaultAuthorizationService) CreateAuthentication(ctx context.Context, request oauth2.OAuth2Request, user security.Authentication) (oauth oauth2.Authentication, err error)
func (*DefaultAuthorizationService) RefreshAccessToken ¶
func (s *DefaultAuthorizationService) RefreshAccessToken(c context.Context, oauth oauth2.Authentication, refreshToken oauth2.RefreshToken) (oauth2.AccessToken, error)
func (*DefaultAuthorizationService) SwitchAuthentication ¶
func (s *DefaultAuthorizationService) SwitchAuthentication(ctx context.Context, request oauth2.OAuth2Request, user security.Authentication, src oauth2.Authentication) (oauth oauth2.Authentication, err error)
type DefaultAuthorizeHandler ¶
type DefaultAuthorizeHandler struct {
// contains filtered or unexported fields
}
DefaultAuthorizeHandler implements AuthorizeHandler it implement standard OAuth2 responses and keep a list of extensions for additional protocols such as OpenID Connect
func NewAuthorizeHandler ¶
func NewAuthorizeHandler(opts ...AuthHandlerOptions) *DefaultAuthorizeHandler
func (*DefaultAuthorizeHandler) Extend ¶
func (h *DefaultAuthorizeHandler) Extend(makers ...AuthorizeHandler) *DefaultAuthorizeHandler
func (*DefaultAuthorizeHandler) HandleApprovalPage ¶
func (h *DefaultAuthorizeHandler) HandleApprovalPage(ctx context.Context, r *AuthorizeRequest, user security.Authentication) (ResponseHandlerFunc, error)
func (*DefaultAuthorizeHandler) HandleApproved ¶
func (h *DefaultAuthorizeHandler) HandleApproved(ctx context.Context, r *AuthorizeRequest, user security.Authentication) (ResponseHandlerFunc, error)
func (*DefaultAuthorizeHandler) MakeAuthCodeResponse ¶
func (h *DefaultAuthorizeHandler) MakeAuthCodeResponse(ctx context.Context, r *AuthorizeRequest, user oauth2.UserAuthentication) (ResponseHandlerFunc, error)
func (*DefaultAuthorizeHandler) MakeImplicitResponse ¶
func (h *DefaultAuthorizeHandler) MakeImplicitResponse(ctx context.Context, r *AuthorizeRequest, user oauth2.UserAuthentication) (ResponseHandlerFunc, error)
type DefaultOAuth2Client ¶
type DefaultOAuth2Client struct {
ClientDetails
}
DefaultOAuth2Client implements security.Account & OAuth2Client
func NewClientWithDetails ¶
func NewClientWithDetails(clientDetails ClientDetails) *DefaultOAuth2Client
func (*DefaultOAuth2Client) AccessTokenValidity ¶
func (c *DefaultOAuth2Client) AccessTokenValidity() time.Duration
func (*DefaultOAuth2Client) AssignedTenantIds ¶
func (c *DefaultOAuth2Client) AssignedTenantIds() utils.StringSet
func (*DefaultOAuth2Client) AutoApproveScopes ¶
func (c *DefaultOAuth2Client) AutoApproveScopes() utils.StringSet
func (*DefaultOAuth2Client) CacheableCopy ¶
func (c *DefaultOAuth2Client) CacheableCopy() security.Account
func (*DefaultOAuth2Client) ClientId ¶
func (c *DefaultOAuth2Client) ClientId() string
* OAuth2Client *
func (*DefaultOAuth2Client) Credentials ¶
func (c *DefaultOAuth2Client) Credentials() interface{}
func (*DefaultOAuth2Client) Disabled ¶
func (c *DefaultOAuth2Client) Disabled() bool
func (*DefaultOAuth2Client) GrantTypes ¶
func (c *DefaultOAuth2Client) GrantTypes() utils.StringSet
func (*DefaultOAuth2Client) ID ¶
func (c *DefaultOAuth2Client) ID() interface{}
func (*DefaultOAuth2Client) Locked ¶
func (c *DefaultOAuth2Client) Locked() bool
func (*DefaultOAuth2Client) MaxTokensPerUser ¶
func (c *DefaultOAuth2Client) MaxTokensPerUser() int
func (*DefaultOAuth2Client) Permissions ¶
func (c *DefaultOAuth2Client) Permissions() []string
func (*DefaultOAuth2Client) RedirectUris ¶
func (c *DefaultOAuth2Client) RedirectUris() utils.StringSet
func (*DefaultOAuth2Client) RefreshTokenValidity ¶
func (c *DefaultOAuth2Client) RefreshTokenValidity() time.Duration
func (*DefaultOAuth2Client) ResourceIDs ¶
func (c *DefaultOAuth2Client) ResourceIDs() utils.StringSet
func (*DefaultOAuth2Client) Scopes ¶
func (c *DefaultOAuth2Client) Scopes() utils.StringSet
func (*DefaultOAuth2Client) Secret ¶
func (c *DefaultOAuth2Client) Secret() string
func (*DefaultOAuth2Client) SecretRequired ¶
func (c *DefaultOAuth2Client) SecretRequired() bool
func (*DefaultOAuth2Client) Type ¶
func (c *DefaultOAuth2Client) Type() security.AccountType
func (*DefaultOAuth2Client) UseMFA ¶
func (c *DefaultOAuth2Client) UseMFA() bool
func (*DefaultOAuth2Client) UseSessionTimeout ¶
func (c *DefaultOAuth2Client) UseSessionTimeout() bool
func (*DefaultOAuth2Client) Username ¶
func (c *DefaultOAuth2Client) Username() string
type DetailsTokenEnhancer ¶
type DetailsTokenEnhancer struct{}
DetailsTokenEnhancer implements order.Ordered and TokenEnhancer it populate token's additional metadata other than claims, issue/expiry time
func (*DetailsTokenEnhancer) Enhance ¶
func (e *DetailsTokenEnhancer) Enhance(_ context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error)
func (*DetailsTokenEnhancer) Order ¶
func (e *DetailsTokenEnhancer) Order() int
type ExpiryTokenEnhancer ¶
type ExpiryTokenEnhancer struct{}
ExpiryTokenEnhancer implements order.Ordered and TokenEnhancer
func (*ExpiryTokenEnhancer) Enhance ¶
func (e *ExpiryTokenEnhancer) Enhance(_ context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error)
func (*ExpiryTokenEnhancer) Order ¶
func (e *ExpiryTokenEnhancer) Order() int
type JTSOption ¶
type JTSOption struct { Reader oauth2.TokenStoreReader DetailsStore security.ContextDetailsStore Encoder jwt.JwtEncoder Decoder jwt.JwtDecoder AuthRegistry AuthorizationRegistry }
type JTSOptions ¶
type JTSOptions func(opt *JTSOption)
type LegacyTokenEnhancer ¶
type LegacyTokenEnhancer struct{}
LegacyTokenEnhancer implements order.Ordered and TokenEnhancer LegacyTokenEnhancer add legacy claims and response fields that was supported by Java version of IDM but deprecated in Go version
func (*LegacyTokenEnhancer) Enhance ¶
func (te *LegacyTokenEnhancer) Enhance(_ context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error)
func (*LegacyTokenEnhancer) Order ¶
func (te *LegacyTokenEnhancer) Order() int
type OAuth2ClientAccountStore ¶
type OAuth2ClientAccountStore struct {
oauth2.OAuth2ClientStore
}
OAuth2ClientAccountStore wraps an delegate and implement both security.AccountStore and client oauth2.OAuth2ClientStore
func WrapOAuth2ClientStore ¶
func WrapOAuth2ClientStore(clientStore oauth2.OAuth2ClientStore) *OAuth2ClientAccountStore
func (*OAuth2ClientAccountStore) LoadAccountById ¶
func (s *OAuth2ClientAccountStore) LoadAccountById(ctx context.Context, id interface{}) (security.Account, error)
security.AccountStore
func (*OAuth2ClientAccountStore) LoadAccountByUsername ¶
func (s *OAuth2ClientAccountStore) LoadAccountByUsername(ctx context.Context, username string) (security.Account, error)
security.AccountStore
func (*OAuth2ClientAccountStore) LoadLockingRules ¶
func (s *OAuth2ClientAccountStore) LoadLockingRules(ctx context.Context, acct security.Account) (security.AccountLockingRule, error)
security.AccountStore
func (*OAuth2ClientAccountStore) LoadPwdAgingRules ¶
func (s *OAuth2ClientAccountStore) LoadPwdAgingRules(ctx context.Context, acct security.Account) (security.AccountPwdAgingRule, error)
security.AccountStore
type OAuth2ErrorHandler ¶
type OAuth2ErrorHandler struct{}
OAuth2ErrorHandler implements security.ErrorHandler It's responsible to handle all oauth2 errors
func NewOAuth2ErrorHandler ¶
func NewOAuth2ErrorHandler() *OAuth2ErrorHandler
func (*OAuth2ErrorHandler) HandleError ¶
func (h *OAuth2ErrorHandler) HandleError(c context.Context, r *http.Request, rw http.ResponseWriter, err error)
HandleError implements security.ErrorHandler
type OverrideAuthOptions ¶
type OverrideAuthOptions func(userAuth security.Authentication) oauth2.UserAuthOptions
OverrideAuthOptions allows the oauth2.UserAuthOptions to be overridden during the conversion when creating and returning a new user authentication.
type RedisAuthorizationCodeStore ¶
type RedisAuthorizationCodeStore struct {
// contains filtered or unexported fields
}
RedisAuthorizationCodeStore store authorization code in Redis
func NewRedisAuthorizationCodeStore ¶
func NewRedisAuthorizationCodeStore(ctx context.Context, cf redis.ClientFactory, dbIndex int) *RedisAuthorizationCodeStore
func (*RedisAuthorizationCodeStore) ConsumeAuthorizationCode ¶
func (s *RedisAuthorizationCodeStore) ConsumeAuthorizationCode(ctx context.Context, authCode string, onetime bool) (oauth2.Authentication, error)
func (*RedisAuthorizationCodeStore) GenerateAuthorizationCode ¶
func (s *RedisAuthorizationCodeStore) GenerateAuthorizationCode(ctx context.Context, r *AuthorizeRequest, user security.Authentication) (string, error)
type RefreshTokenEnhancer ¶
type RefreshTokenEnhancer struct {
// contains filtered or unexported fields
}
RefreshTokenEnhancer implements order.Ordered and TokenEnhancer RefreshTokenEnhancer is responsible to create refresh token and associate it with the given access token
func (*RefreshTokenEnhancer) Enhance ¶
func (te *RefreshTokenEnhancer) Enhance(ctx context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error)
func (*RefreshTokenEnhancer) Order ¶
func (te *RefreshTokenEnhancer) Order() int
type ResourceIdTokenEnhancer ¶
type ResourceIdTokenEnhancer struct { }
ResourceIdTokenEnhancer impelments order.Ordered and TokenEnhancer spring-security-oauth2 based java implementation expecting "aud" claims to be the resource ID
func (*ResourceIdTokenEnhancer) Enhance ¶
func (te *ResourceIdTokenEnhancer) Enhance(c context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error)
func (*ResourceIdTokenEnhancer) Order ¶
func (te *ResourceIdTokenEnhancer) Order() int
type ResponseHandlerFunc ¶
type RevokerTokenHint ¶
type RevokerTokenHint string
const ( RevokerHintAccessToken RevokerTokenHint = "access_token" RevokerHintRefreshToken RevokerTokenHint = "refresh_token" )
type StandardAuthorizeRequestProcessor ¶
type StandardAuthorizeRequestProcessor struct {
// contains filtered or unexported fields
}
StandardAuthorizeRequestProcessor implements ChainedAuthorizeRequestProcessor and order.Ordered it validate auth request against standard oauth2 specs
func NewStandardAuthorizeRequestProcessor ¶
func NewStandardAuthorizeRequestProcessor(opts ...StdARPOptions) *StandardAuthorizeRequestProcessor
func (*StandardAuthorizeRequestProcessor) Process ¶
func (p *StandardAuthorizeRequestProcessor) Process(ctx context.Context, request *AuthorizeRequest, chain AuthorizeRequestProcessChain) (validated *AuthorizeRequest, err error)
type StdARPOption ¶
type StdARPOption struct { ClientStore oauth2.OAuth2ClientStore AccountStore security.AccountStore }
type StdARPOptions ¶
type StdARPOptions func(*StdARPOption)
type TokenEnhancer ¶
type TokenEnhancer interface {
Enhance(ctx context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error)
}
TokenEnhancer modify given oauth2.AccessToken or return a new token based on given context and auth Most TokenEnhancer responsible to add/modify claims of given access token But it's not limited to do so. e.g. TokenEnhancer could be responsible to install refresh token Usually if given token is not mutable, the returned token would be different instance
type TokenGranter ¶
type TokenGranter interface { // Grant create oauth2.AccessToken based on given TokenRequest // returns // - (nil, nil) if the TokenGranter doesn't support given request // - (non-nil, nil) if the TokenGranter support given request and created a token without error // - (nil, non-nil) if the TokenGranter support given request but rejected the request Grant(ctx context.Context, request *TokenRequest) (oauth2.AccessToken, error) }
type TokenRequest ¶
type TokenRequest struct { Parameters map[string]string ClientId string Scopes utils.StringSet GrantType string Extensions map[string]interface{} // contains filtered or unexported fields }
func NewTokenRequest ¶
func NewTokenRequest() *TokenRequest
func ParseTokenRequest ¶
func ParseTokenRequest(req *http.Request) (*TokenRequest, error)
func (*TokenRequest) Context ¶
func (r *TokenRequest) Context() utils.MutableContext
func (*TokenRequest) OAuth2Request ¶
func (r *TokenRequest) OAuth2Request(client oauth2.OAuth2Client) oauth2.OAuth2Request
func (*TokenRequest) String ¶
func (r *TokenRequest) String() string
func (*TokenRequest) WithContext ¶
func (r *TokenRequest) WithContext(ctx context.Context) *TokenRequest
type TokenStore ¶
type TokenStore interface { oauth2.TokenStoreReader // ReusableAccessToken finds access token that currently associated with given oauth2.Authentication // and can be reused ReusableAccessToken(ctx context.Context, oauth oauth2.Authentication) (oauth2.AccessToken, error) // SaveAccessToken associate given oauth2.Authentication with the to-be-saved oauth2.AccessToken. // It returns the saved oauth2.AccessToken or error. // The saved oauth2.AccessToken may be different from given oauth2.AccessToken (e.g. JWT encoded token) SaveAccessToken(ctx context.Context, token oauth2.AccessToken, oauth oauth2.Authentication) (oauth2.AccessToken, error) // SaveRefreshToken associate given oauth2.Authentication with the to-be-saved oauth2.RefreshToken. // It returns the saved oauth2.RefreshToken or error. // The saved oauth2.RefreshToken may be different from given oauth2.RefreshToken (e.g. JWT encoded token) SaveRefreshToken(ctx context.Context, token oauth2.RefreshToken, oauth oauth2.Authentication) (oauth2.RefreshToken, error) // RemoveAccessToken remove oauth2.AccessToken using given token value. // Token can be oauth2.AccessToken or oauth2.RefreshToken RemoveAccessToken(ctx context.Context, token oauth2.Token) error // RemoveRefreshToken remove given oauth2.RefreshToken RemoveRefreshToken(ctx context.Context, token oauth2.RefreshToken) error }
Source Files ¶
- authorize_code_store.go
- authorize_handler.go
- authorize_request.go
- authorize_validation.go
- authorize_validation_std.go
- client.go
- client_store.go
- common.go
- constants.go
- error_handling.go
- granter.go
- package.go
- redirect.go
- registry.go
- revoker.go
- service.go
- token_enhance.go
- token_enhance_common.go
- token_enhance_legacy.go
- token_enhance_refresh.go
- token_request.go
- token_store.go
- token_store_jwt.go
- wildcard.go