Documentation ¶
Index ¶
- Variables
- func Anonymous() *identity
- func Authenticated(id uint64, rr ...uint64) *identity
- func DefaultAccessTokenGenerator(ctx context.Context, req TokenRequest) (string, string, error)
- func ExtractFromSubClaim(sub string) (userID uint64, rr []uint64)
- func HttpTokenValidator(scope ...string) func(http.Handler) http.Handler
- func IdentityFromToken(token jwt.Token) *identity
- func NewTokenIssuer(opt ...IssuerOptFn) (issuer *tokenIssuer, err error)
- func SetIdentityToContext(ctx context.Context, identity Identifiable) context.Context
- func TokenVerifierMiddlewareWithSecretSigner(secret string) (_ func(http.Handler) http.Handler, err error)
- type Identifiable
- type IssueOptFn
- type IssuerOptFn
- func WithDefaultClientID(ID uint64) IssuerOptFn
- func WithDefaultExpiration(exp time.Duration) IssuerOptFn
- func WithDefaultIssuer(iss string) IssuerOptFn
- func WithGenerator(fn tokenIssuerGenerator) IssuerOptFn
- func WithLookup(fn tokenIssuerLookup) IssuerOptFn
- func WithSecretSigner(secret string) IssuerOptFn
- func WithSigner(fn tokenIssuerSigner) IssuerOptFn
- func WithStore(fn tokenIssuerStore) IssuerOptFn
- type Signer
- type TokenRequest
Constants ¶
This section is empty.
Variables ¶
var (
HttpTokenVerifier func(http.Handler) http.Handler
)
var (
TokenIssuer *tokenIssuer
)
Functions ¶
func Anonymous ¶
func Anonymous() *identity
Anonymous constructs and returns new anonymous identity with system anonymous roles
func Authenticated ¶
Authenticated constructs and returns new authenticated identity with assigned roles + system authenticated roles
func DefaultAccessTokenGenerator ¶
DefaultAccessTokenGenerator uses token generator from oauth2 lib
func ExtractFromSubClaim ¶
func HttpTokenValidator ¶
HttpTokenValidator checks if there is a token with identity and matching scope claim
Empty scope defaults to "api"!
func IdentityFromToken ¶
IdentityFromToken decodes sub & roles claims into identity
func NewTokenIssuer ¶
func NewTokenIssuer(opt ...IssuerOptFn) (issuer *tokenIssuer, err error)
NewTokenIssuer initializes and returns new instance of JWT manager
func SetIdentityToContext ¶
func SetIdentityToContext(ctx context.Context, identity Identifiable) context.Context
Types ¶
type Identifiable ¶
type IssueOptFn ¶
type IssueOptFn func(*TokenRequest) error
IssueOptFn functions modify TokenRequest
func WithAccessToken ¶
func WithAccessToken(access string) IssueOptFn
func WithAudience ¶
func WithAudience(aud string) IssueOptFn
func WithClientID ¶
func WithClientID(id uint64) IssueOptFn
func WithExpiration ¶
func WithExpiration(e time.Duration) IssueOptFn
func WithIdentity ¶
func WithIdentity(i Identifiable) IssueOptFn
func WithScope ¶
func WithScope(ss ...string) IssueOptFn
type IssuerOptFn ¶
type IssuerOptFn func(*tokenIssuer) error
IssuerOptFn modify toeknIssuer
func WithDefaultClientID ¶
func WithDefaultClientID(ID uint64) IssuerOptFn
WithDefaultClientID configures ID of the default auth client
func WithDefaultExpiration ¶
func WithDefaultExpiration(exp time.Duration) IssuerOptFn
WithDefaultExpiration configures default token expiration time
func WithDefaultIssuer ¶
func WithDefaultIssuer(iss string) IssuerOptFn
WithDefaultIssuer configures default issuer claim
func WithGenerator ¶
func WithGenerator(fn tokenIssuerGenerator) IssuerOptFn
WithGenerator configures generator function
func WithLookup ¶
func WithLookup(fn tokenIssuerLookup) IssuerOptFn
WithLookup configures lookup function
func WithSecretSigner ¶
func WithSecretSigner(secret string) IssuerOptFn
WithSecretSigner configures token issuer with
func WithSigner ¶
func WithSigner(fn tokenIssuerSigner) IssuerOptFn
WithSigner configures signer function
func WithStore ¶
func WithStore(fn tokenIssuerStore) IssuerOptFn
WithStore configures store function