Documentation
¶
Index ¶
- Constants
- Variables
- func HasPermission(identity *Identity, permission string) bool
- func RoleID(c identityContext) int64
- func UserID(c identityContext) int64
- type AnonymousAuthenticator
- type ChainAuthenticator
- type Credential
- type Extractor
- type ExtractorFunc
- type Identity
- type IdentityFailureHook
- type IdentityHook
- type IdentityRefresher
- type IdentityValidator
- type JWTAuthenticator
- type JWTAuthenticatorOption
- type JWTClaims
- type JWTConfig
- type LoginResult
- type RequestAuthenticator
- type RequestAuthenticatorFunc
- type SessionAuthenticator
- type SessionMapper
- type SessionReader
Constants ¶
View Source
const ( CredentialBearer = "bearer" CredentialQuery = "query" CredentialCookie = "cookie" CredentialSession = "session" )
View Source
const ( ContextIdentityKey = "auth.identity" ContextIdentity = ContextIdentityKey )
View Source
const ( MethodJWT = "jwt" MethodSession = "session" MethodAnonymous = "anonymous" )
Variables ¶
View Source
var ( ErrInvalidCredentials = errors.New("invalid credentials") ErrAccountDisabled = errors.New("account disabled") )
Functions ¶
func HasPermission ¶
Types ¶
type AnonymousAuthenticator ¶ added in v0.1.2
type AnonymousAuthenticator struct{}
func (AnonymousAuthenticator) AuthenticateRequest ¶ added in v0.1.2
type ChainAuthenticator ¶ added in v0.1.2
type ChainAuthenticator struct {
// contains filtered or unexported fields
}
func NewChainAuthenticator ¶ added in v0.1.2
func NewChainAuthenticator(authenticators ...RequestAuthenticator) *ChainAuthenticator
func (*ChainAuthenticator) AuthenticateRequest ¶ added in v0.1.2
type Credential ¶ added in v0.1.2
type Extractor ¶ added in v0.1.2
type Extractor interface {
Extract(*http.Request) (Credential, bool)
}
func BearerTokenExtractor ¶ added in v0.1.2
func BearerTokenExtractor() Extractor
func CookieTokenExtractor ¶ added in v0.1.2
func FirstExtractor ¶ added in v0.1.2
func QueryTokenExtractor ¶ added in v0.1.2
type ExtractorFunc ¶ added in v0.1.2
type ExtractorFunc func(*http.Request) (Credential, bool)
func (ExtractorFunc) Extract ¶ added in v0.1.2
func (f ExtractorFunc) Extract(r *http.Request) (Credential, bool)
type Identity ¶
type Identity struct {
SubjectID int64
Subject string
SubjectType string
TenantID int64
Username string
RoleID int64
Roles []string
Permissions []string
Method string
Provider string
SessionID string
TokenID string
ExpiresAt time.Time
Extra map[string]any
}
func CurrentIdentity ¶
func CurrentIdentity(c identityContext) *Identity
func (*Identity) Authenticated ¶ added in v0.1.2
func (*Identity) SubjectKey ¶ added in v0.1.2
type IdentityFailureHook ¶ added in v0.1.2
type IdentityHook ¶ added in v0.1.2
type IdentityRefresher ¶ added in v0.1.2
type IdentityRefresher = IdentityHook
type IdentityValidator ¶ added in v0.1.2
type IdentityValidator = IdentityHook
type JWTAuthenticator ¶ added in v0.1.2
type JWTAuthenticator struct {
// contains filtered or unexported fields
}
func NewJWTAuthenticator ¶ added in v0.1.2
func NewJWTAuthenticator(cfg *JWTConfig, opts ...JWTAuthenticatorOption) *JWTAuthenticator
func (*JWTAuthenticator) AuthenticateRequest ¶ added in v0.1.2
func (*JWTAuthenticator) Login ¶ added in v0.1.2
func (a *JWTAuthenticator) Login(ctx context.Context, identity *Identity) (*LoginResult, error)
type JWTAuthenticatorOption ¶ added in v0.1.2
type JWTAuthenticatorOption func(*JWTAuthenticator)
func WithJWTExtractor ¶ added in v0.1.2
func WithJWTExtractor(extractor Extractor) JWTAuthenticatorOption
func WithJWTProvider ¶ added in v0.1.2
func WithJWTProvider(provider string) JWTAuthenticatorOption
type JWTClaims ¶
type JWTClaims = jwtx.SubjectClaims
type LoginResult ¶
type RequestAuthenticator ¶ added in v0.1.2
type RequestAuthenticatorFunc ¶ added in v0.1.2
func (RequestAuthenticatorFunc) AuthenticateRequest ¶ added in v0.1.2
type SessionAuthenticator ¶ added in v0.1.2
type SessionAuthenticator struct {
Provider string
Key string
Reader SessionReader
Mapper SessionMapper
Validator IdentityValidator
Validators []IdentityHook
Refresher IdentityRefresher
Refreshers []IdentityHook
Failure IdentityFailureHook
Failures []IdentityFailureHook
}
func NewSessionAuthenticator ¶ added in v0.1.2
func NewSessionAuthenticator(opts SessionAuthenticator) *SessionAuthenticator
func (*SessionAuthenticator) AuthenticateRequest ¶ added in v0.1.2
type SessionMapper ¶ added in v0.1.2
Source Files
¶
Click to show internal directories.
Click to hide internal directories.