Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewMiddleware ¶
func NewMiddleware(configFuncs ...ConfigFunc) middleware.Middleware
func RegisterProvider ¶
func RegisterProvider(name ProviderName, provider Provider)
RegisterProvider registers Provider with ProviderName
Types ¶
type ConfigFunc ¶
type ConfigFunc func(c *config)
func AllowEmptyIdentity ¶
func AllowEmptyIdentity() ConfigFunc
AllowEmptyIdentity allows unauthorized request to middleware
func UseCustomEmptyIdentityError ¶
func UseCustomEmptyIdentityError(e *errors.Error) ConfigFunc
UseCustomEmptyIdentityError defines custom emptyIdentityError as e
func UseCustomEmptyIdentityErrorBuilder ¶ added in v0.0.2
func UseCustomEmptyIdentityErrorBuilder(f func(ctx context.Context) *errors.Error) ConfigFunc
UseCustomEmptyIdentityErrorBuilder defines custom emptyIdentityErrorBuilder as f
func UseProviders ¶
func UseProviders(names []ProviderName) ConfigFunc
UseProviders defines Provider(s) that will be used in middleware as given ProviderName(s).
type Identity ¶
type Identity struct { // ProviderName is name of authenticated Provider ProviderName ProviderName // Identifier is unique id of authenticated user/agent Identifier string // Extra is field for adding custom data Extra interface{} }
Identity represents authenticated identity
func IdentityFromContext ¶
IdentityFromContext returns Identity which stored in context.Context. NOTE: Identity can be empty depends on config. If you defined emptyIdentityError as nil, you must check emptiness with Identity.Empty()
type Provider ¶
type Provider interface { // Name returns registered ProviderName Name() ProviderName // Authenticate extracts Identity from server context and request // If you return non-nil error as second parameter, middleware will respond error directly. // Error must be errors.Error of kratos Authenticate(ctx context.Context, req interface{}) (*Identity, *errors.Error) }
Click to show internal directories.
Click to hide internal directories.