authn

package
v1.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 13, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
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

func WithLogger(logger log.Logger) options.Option

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL