tokenauth

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Apr 24, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	FeatureId = security.FeatureId("OAuth2TokenAuth", security.FeatureOrderOAuth2TokenAuth)
)
View Source
var Module = &bootstrap.Module{
	Name:       "oauth2 resource server",
	Precedence: security.MinSecurityPrecedence + 20,
	Options:    []fx.Option{},
}

Functions

func RequireScopes

func RequireScopes(scopes ...string) access.ControlCondition

RequireScopes returns ControlCondition using ScopesApproved

func ScopesApproved

func ScopesApproved(scopes ...string) access.ControlFunc

Types

type Authenticator

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

func NewAuthenticator

func NewAuthenticator(options ...AuthenticatorOptions) *Authenticator

func (*Authenticator) Authenticate

func (a *Authenticator) Authenticate(ctx context.Context, candidate security.Candidate) (security.Authentication, error)

type AuthenticatorOption

type AuthenticatorOption struct {
	TokenStoreReader oauth2.TokenStoreReader
}

type AuthenticatorOptions

type AuthenticatorOptions func(opt *AuthenticatorOption)

type BearerToken

type BearerToken struct {
	Token      string
	DetailsMap map[string]interface{}
}

BearerToken is the supported security.Candidate of resource server authenticator

func (*BearerToken) Credentials

func (t *BearerToken) Credentials() interface{}

func (*BearerToken) Details

func (t *BearerToken) Details() interface{}

func (*BearerToken) Principal

func (t *BearerToken) Principal() interface{}

type OAuth2ErrorHandler

type OAuth2ErrorHandler struct{}

OAuth2ErrorHandler implements security.ErrorHandler It's responsible to handle all oauth2 errors

func NewOAuth2ErrorHanlder

func NewOAuth2ErrorHanlder() *OAuth2ErrorHandler

func (*OAuth2ErrorHandler) HandleError

func (h *OAuth2ErrorHandler) HandleError(c context.Context, r *http.Request, rw http.ResponseWriter, err error)

HandleError implements security.ErrorHandler

type TokenAuthConfigurer

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

func NewTokenAuthConfigurer

func NewTokenAuthConfigurer(opts ...TokenAuthOptions) *TokenAuthConfigurer

func (*TokenAuthConfigurer) Apply

func (c *TokenAuthConfigurer) Apply(feature security.Feature, ws security.WebSecurity) (err error)

type TokenAuthFeature

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

func Configure

func Configure(ws security.WebSecurity) *TokenAuthFeature

Configure Standard security.Feature entrypoint use (*access.AccessControl).AllowIf(ScopesApproved(...)) for scope based access decision maker

func New

func New() *TokenAuthFeature

New Standard security.Feature entrypoint, DSL style. Used with security.WebSecurity use (*access.AccessControl).AllowIf(ScopesApproved(...)) for scope based access decision maker

func (*TokenAuthFeature) EnablePostBody

func (f *TokenAuthFeature) EnablePostBody() *TokenAuthFeature

func (*TokenAuthFeature) ErrorHandler

func (f *TokenAuthFeature) ErrorHandler(errorHandler *OAuth2ErrorHandler) *TokenAuthFeature

func (*TokenAuthFeature) Identifier

type TokenAuthMWOption

type TokenAuthMWOption struct {
	Authenticator   security.Authenticator
	SuccessHandler  security.AuthenticationSuccessHandler
	PostBodyEnabled bool
}

type TokenAuthMWOptions

type TokenAuthMWOptions func(opt *TokenAuthMWOption)

type TokenAuthMiddleware

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

func NewTokenAuthMiddleware

func NewTokenAuthMiddleware(opts ...TokenAuthMWOptions) *TokenAuthMiddleware

func (*TokenAuthMiddleware) AuthenticateHandlerFunc

func (mw *TokenAuthMiddleware) AuthenticateHandlerFunc() gin.HandlerFunc

type TokenAuthOption

type TokenAuthOption struct {
	TokenStoreReader oauth2.TokenStoreReader
}

type TokenAuthOptions

type TokenAuthOptions func(opt *TokenAuthOption)

Jump to

Keyboard shortcuts

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