authz

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Dec 30, 2025 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MiddlewareName = "authz"
)

Variables

This section is empty.

Functions

func NoOpSkipChecker

func NoOpSkipChecker() security.SkipChecker

NoOpSkipChecker creates a SkipChecker that never skips authorization.

func PathSkipChecker

func PathSkipChecker(skipPaths ...string) security.SkipChecker

PathSkipChecker creates a SkipChecker that skips authorization for specified operation paths.

func WithAuthorizer

func WithAuthorizer(authorizer authz.Authorizer) options.Option

WithAuthorizer provides an Authorizer via a runtime option.

func WithSkipChecker

func WithSkipChecker(skipChecker security.SkipChecker) options.Option

WithSkipChecker provides a SkipChecker via a runtime option.

Types

type Middleware

type Middleware struct {
	*Options
}

Middleware is a Kratos middleware for authorization. It embeds the Options struct to hold its configuration.

func New

func New(authorizer authz.Authorizer, opts ...options.Option) *Middleware

New is a convenience function for creating a new authorization middleware for manual use.

func (*Middleware) Client

func (m *Middleware) Client() middleware.KMiddleware

Client implements the Kratos middleware. For authorization, this is typically a no-op.

func (*Middleware) Server

func (m *Middleware) Server() middleware.KMiddleware

Server implements the Kratos middleware.

type Options

type Options struct {
	Authorizer  authz.Authorizer
	SkipChecker security.SkipChecker
}

Options holds configurations for the authz middleware.

Jump to

Keyboard shortcuts

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