Documentation
¶
Index ¶
- Constants
- func NoOpSkipChecker() security.SkipChecker
- func PathSkipChecker(skipPaths ...string) security.SkipChecker
- func WithAuthenticator(authenticator authn.Authenticator) options.Option
- func WithLogger(logger log.Logger) options.Option
- func WithSkipChecker(skipChecker security.SkipChecker) options.Option
- type Middleware
- type Options
Constants ¶
const (
MiddlewareName = "authn"
)
Variables ¶
This section is empty.
Functions ¶
func NoOpSkipChecker ¶
func NoOpSkipChecker() security.SkipChecker
NoOpSkipChecker creates a SkipChecker that never skips authentication. This is the default behavior.
func PathSkipChecker ¶
func PathSkipChecker(skipPaths ...string) security.SkipChecker
PathSkipChecker creates a SkipChecker that skips authentication for specified operation paths. This is provided for convenience, delegating to the common helper.
func WithAuthenticator ¶
func WithAuthenticator(authenticator authn.Authenticator) options.Option
WithAuthenticator provides an Authenticator via a runtime option.
func WithLogger ¶ added in v1.3.0
WithLogger sets the logger for the middleware.
func WithSkipChecker ¶
func WithSkipChecker(skipChecker security.SkipChecker) options.Option
WithSkipChecker provides a SkipChecker via a runtime option.
Types ¶
type Middleware ¶
type Middleware struct {
*Options
// contains filtered or unexported fields
}
Middleware is a Kratos middleware for authentication.
func New ¶
func New(authenticator authn.Authenticator, opts ...options.Option) *Middleware
New is a convenience function for creating a new authentication middleware for manual use.
func (*Middleware) Client ¶
func (m *Middleware) Client() middleware.KMiddleware
Client implements the Kratos middleware.
func (*Middleware) Server ¶
func (m *Middleware) Server() middleware.KMiddleware
Server implements the Kratos middleware.
type Options ¶
type Options struct {
Authenticator authn.Authenticator
SkipChecker security.SkipChecker
Logger log.Logger
}
Options holds configurations for the authn middleware, parsed from a generic options slice.