Documentation ¶
Overview ¶
Package security implements the functions, types, and interfaces for the module.
Package security implements the functions, types, and interfaces for the module.
Package security implements the functions, types, and interfaces for the module.
Package security implements the functions, types, and interfaces for the module.
Package security implements the functions, types, and interfaces for the module.
Package security implements the functions, types, and interfaces for the module.
Index ¶
- Constants
- Variables
- func ClaimFromTokenTypeContext(ctx context.Context, tokenType security.TokenType) (security.Claims, error)
- func ClaimsFromContext(ctx context.Context) security.Claims
- func FromMetaData(key string) func(ctx context.Context) string
- func FromMetaDataKey(ctx context.Context, key string) string
- func FromTransportClient(authorize string, scheme string) func(ctx context.Context) string
- func FromTransportServer(authorize string, scheme string) func(ctx context.Context) string
- func IsSkipped(ctx context.Context, key string) bool
- func NewAuthN(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
- func NewAuthNClient(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
- func NewAuthNServer(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
- func NewAuthZ(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
- func NewAuthZClient(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
- func NewAuthZServer(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
- func NewClaimsContext(ctx context.Context, claims security.Claims) context.Context
- func NewSkipContext(ctx context.Context) context.Context
- func NewTokenContext(ctx context.Context, token string) context.Context
- func NewUserClaimsContext(ctx context.Context, claims security.UserClaims) context.Context
- func SkipFromContext(ctx context.Context) bool
- func Skipper(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, bool)
- func TokenFromContext(ctx context.Context) string
- func TokenFromTypeContext(ctx context.Context, tokenType security.TokenType, scheme string) (string, error)
- func TokenToTypeContext(ctx context.Context, tokenType security.TokenType, scheme string, token string) context.Context
- func UserClaimsFromContext(ctx context.Context) security.UserClaims
- func UserClaimsFromMetaData(ctx context.Context, key string) string
- func UserClaimsToMetaData(ctx context.Context, key string, value string) context.Context
- func WithSkipContextClient(ctx context.Context, key string) context.Context
- func WithSkipContextServer(ctx context.Context, key string) context.Context
- type Option
- type OptionSetting
- func WithAuthenticator(authenticator security.Authenticator) OptionSetting
- func WithAuthorizer(authorizer security.Authorizer) OptionSetting
- func WithConfig(cfg *configv1.Security) OptionSetting
- func WithSkipKey(key string) OptionSetting
- func WithSkipper(paths ...string) OptionSetting
- func WithTokenKey(key string) OptionSetting
- type ResponseWriter
- type TokenParser
Constants ¶
const ( MetadataAuthZ = "x-metadata-security-authz" MetadataAuthN = "x-metadata-security-authn" MetadataSecurityTokenKey = "x-metadata-security-token-key" MetadataSecuritySkipKey = "x-metadata-security-skip-key" )
const ( StringBoolTrue = "true" StringBoolFalse = "false" )
const (
ErrorCreateOptionNil = errors.String("authenticator middleware create failed: option is nil")
)
Variables ¶
var ( ErrInvalidToken = securityv1.ErrorAuthErrorReasonBearerTokenMissing("bearer token missing") ErrInvalidClaims = securityv1.ErrorAuthErrorReasonInvalidClaims("invalid bearer token") ErrMissingClaims = securityv1.ErrorAuthErrorReasonInvalidClaims("missing scheme") ErrMissingToken = securityv1.ErrorAuthErrorReasonBearerTokenMissing("bearer token missing") ErrInvalidAuth = securityv1.ErrorAuthErrorReasonUnauthenticated("unauthenticated") )
Functions ¶
func ClaimFromTokenTypeContext ¶ added in v0.1.5
func ClaimsFromContext ¶ added in v0.1.0
func FromTransportClient ¶ added in v0.1.0
func FromTransportServer ¶ added in v0.1.0
func NewAuthN ¶ added in v0.1.0
func NewAuthN(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
NewAuthN is a server authenticator middleware.
func NewAuthNClient ¶ added in v0.1.0
func NewAuthNClient(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
NewAuthNClient is a client authenticator middleware.
func NewAuthNServer ¶ added in v0.1.0
func NewAuthNServer(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
NewAuthNServer is a server authenticator middleware.
func NewAuthZ ¶ added in v0.1.5
func NewAuthZ(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
NewAuthZ returns a new server middleware.
func NewAuthZClient ¶ added in v0.1.5
func NewAuthZClient(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
NewAuthZClient returns a new server middleware.
func NewAuthZServer ¶ added in v0.1.0
func NewAuthZServer(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)
NewAuthZServer returns a new server middleware.
func NewClaimsContext ¶ added in v0.1.0
func NewTokenContext ¶ added in v0.1.5
func NewUserClaimsContext ¶ added in v0.1.0
func SkipFromContext ¶ added in v0.1.0
func Skipper ¶ added in v0.1.5
func Skipper(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, bool)
func TokenFromContext ¶ added in v0.1.5
func TokenFromTypeContext ¶ added in v0.1.5
func TokenFromTypeContext(ctx context.Context, tokenType security.TokenType, scheme string) (string, error)
TokenFromTypeContext .
func TokenToTypeContext ¶ added in v0.1.5
func TokenToTypeContext(ctx context.Context, tokenType security.TokenType, scheme string, token string) context.Context
TokenToTypeContext .
func UserClaimsFromContext ¶ added in v0.1.0
func UserClaimsFromContext(ctx context.Context) security.UserClaims
func UserClaimsFromMetaData ¶ added in v0.1.5
func UserClaimsToMetaData ¶ added in v0.1.5
func WithSkipContextClient ¶ added in v0.1.0
Types ¶
type Option ¶ added in v0.1.0
type Option struct { Authorizer security.Authorizer Authenticator security.Authenticator Serializer security.Serializer TokenKey string Scheme string HeaderAuthorize string SkipKey string PublicPaths []string TokenParser func(ctx context.Context) string Parser security.UserClaimsParser Skipper func(string) bool }
func (*Option) ApplyDefaults ¶ added in v0.1.0
func (o *Option) ApplyDefaults()
func (*Option) ParserUserClaims ¶ added in v0.1.5
type OptionSetting ¶ added in v0.1.0
type OptionSetting = func(option *Option)
func WithAuthenticator ¶ added in v0.1.0
func WithAuthenticator(authenticator security.Authenticator) OptionSetting
func WithAuthorizer ¶ added in v0.1.0
func WithAuthorizer(authorizer security.Authorizer) OptionSetting
func WithConfig ¶ added in v0.1.0
func WithConfig(cfg *configv1.Security) OptionSetting
func WithSkipKey ¶ added in v0.1.0
func WithSkipKey(key string) OptionSetting
func WithSkipper ¶ added in v0.1.0
func WithSkipper(paths ...string) OptionSetting
func WithTokenKey ¶ added in v0.1.0
func WithTokenKey(key string) OptionSetting