Documentation ¶
Index ¶
- Constants
- type Middleware
- func (m *Middleware) Basic(ctx context.Context, key string) error
- func (m *Middleware) Bearer(ctx context.Context, tokenString string) (*candishared.TokenClaim, error)
- func (m *Middleware) GRPCBasicAuth(ctx context.Context) (context.Context, error)
- func (m *Middleware) GRPCBearerAuth(ctx context.Context) (context.Context, error)
- func (m *Middleware) GRPCMultipleAuth(ctx context.Context) (context.Context, error)
- func (m *Middleware) GRPCPermissionACL(permissionCode string) types.MiddlewareFunc
- func (m *Middleware) GraphQLAuth(ctx context.Context, directive *gqltypes.Directive, input interface{}) (context.Context, error)
- func (m *Middleware) GraphQLPermissionACL(ctx context.Context, directive *gqltypes.Directive, input interface{}) (context.Context, error)
- func (m *Middleware) HTTPBasicAuth(next http.Handler) http.Handler
- func (m *Middleware) HTTPBearerAuth(next http.Handler) http.Handler
- func (m *Middleware) HTTPCache(next http.Handler) http.Handler
- func (m *Middleware) HTTPMultipleAuth(next http.Handler) http.Handler
- func (m *Middleware) HTTPPermissionACL(permissionCode string) func(http.Handler) http.Handler
- type OptionFunc
- func SetACLPermissionChecker(aclPermissionChecker interfaces.ACLPermissionChecker) OptionFunc
- func SetBasicAuthValidator(basicAuth interfaces.BasicAuthValidator) OptionFunc
- func SetCache(cache interfaces.Cache, defaultCacheAge time.Duration) OptionFunc
- func SetTokenValidator(tokenValidator interfaces.TokenValidator) OptionFunc
- func SetUserIDExtractor(extractor func(tokenClaim *candishared.TokenClaim) (userID string)) OptionFunc
Constants ¶
const ( // BEARER constanta BEARER = "BEARER" // BASIC constanta BASIC = "BASIC" // MULTIPLE constanta MULTIPLE = "MULTIPLE" )
const ( // DefaultCacheAge const DefaultCacheAge = 1 * time.Minute )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Middleware ¶
type Middleware struct {
// contains filtered or unexported fields
}
Middleware impl
func NewMiddleware ¶
func NewMiddleware(tokenValidator interfaces.TokenValidator, aclPermissionChecker interfaces.ACLPermissionChecker) *Middleware
NewMiddleware create new middleware instance (DEPRECATED, use NewMiddlewareWithOption)
func NewMiddlewareWithOption ¶ added in v1.13.9
func NewMiddlewareWithOption(opts ...OptionFunc) *Middleware
NewMiddlewareWithOption create new middleware instance with option
func (*Middleware) Basic ¶
func (m *Middleware) Basic(ctx context.Context, key string) error
Basic function basic auth
func (*Middleware) Bearer ¶
func (m *Middleware) Bearer(ctx context.Context, tokenString string) (*candishared.TokenClaim, error)
Bearer token validator
func (*Middleware) GRPCBasicAuth ¶
GRPCBasicAuth method
func (*Middleware) GRPCBearerAuth ¶
GRPCBearerAuth method
func (*Middleware) GRPCMultipleAuth ¶ added in v1.14.6
GRPCMultipleAuth method
func (*Middleware) GRPCPermissionACL ¶
func (m *Middleware) GRPCPermissionACL(permissionCode string) types.MiddlewareFunc
GRPCPermissionACL grpc interceptor for check acl permission
func (*Middleware) GraphQLAuth ¶ added in v1.12.0
func (m *Middleware) GraphQLAuth(ctx context.Context, directive *gqltypes.Directive, input interface{}) (context.Context, error)
GraphQLAuth for graphql resolver
func (*Middleware) GraphQLPermissionACL ¶
func (m *Middleware) GraphQLPermissionACL(ctx context.Context, directive *gqltypes.Directive, input interface{}) (context.Context, error)
GraphQLPermissionACL graphql resolver for check acl permission
func (*Middleware) HTTPBasicAuth ¶
func (m *Middleware) HTTPBasicAuth(next http.Handler) http.Handler
HTTPBasicAuth http basic auth middleware
func (*Middleware) HTTPBearerAuth ¶
func (m *Middleware) HTTPBearerAuth(next http.Handler) http.Handler
HTTPBearerAuth http jwt token middleware
func (*Middleware) HTTPCache ¶ added in v1.14.6
func (m *Middleware) HTTPCache(next http.Handler) http.Handler
HTTPCache middleware for cache
func (*Middleware) HTTPMultipleAuth ¶
func (m *Middleware) HTTPMultipleAuth(next http.Handler) http.Handler
HTTPMultipleAuth mix basic & bearer auth
func (*Middleware) HTTPPermissionACL ¶
HTTPPermissionACL http middleware for check acl permission
type OptionFunc ¶ added in v1.13.9
type OptionFunc func(*Middleware)
OptionFunc type
func SetACLPermissionChecker ¶ added in v1.13.9
func SetACLPermissionChecker(aclPermissionChecker interfaces.ACLPermissionChecker) OptionFunc
SetACLPermissionChecker option func
func SetBasicAuthValidator ¶ added in v1.13.9
func SetBasicAuthValidator(basicAuth interfaces.BasicAuthValidator) OptionFunc
SetBasicAuthValidator option func
func SetCache ¶ added in v1.14.6
func SetCache(cache interfaces.Cache, defaultCacheAge time.Duration) OptionFunc
SetCache option func
func SetTokenValidator ¶ added in v1.13.9
func SetTokenValidator(tokenValidator interfaces.TokenValidator) OptionFunc
SetTokenValidator option func
func SetUserIDExtractor ¶ added in v1.13.10
func SetUserIDExtractor(extractor func(tokenClaim *candishared.TokenClaim) (userID string)) OptionFunc
SetUserIDExtractor option func, custom extract user id from token claim for acl permission checker