security

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package security implements the functions, types, and interfaces for the module.

Package security implements the functions, types, and interfaces for the module.

Package security implements the functions, types, and interfaces for the module.

Package security implements the functions, types, and interfaces for the module.

Index

Constants

View Source
const (
	MetadataAuthZ            = "x-metadata-security-authz"
	MetadataAuthN            = "x-metadata-security-authn"
	MetadataSecurityTokenKey = "x-metadata-security-token-key"
	MetadataSecuritySkipKey  = "x-metadata-security-skip-key"
)
View Source
const (
	StringBoolTrue  = "true"
	StringBoolFalse = "false"
)
View Source
const (
	ErrorCreateOptionNil = errors.String("authenticator middleware create failed: option is nil")
)

Variables

View Source
var (
	ErrInvalidToken  = securityv1.ErrorAuthErrorReasonBearerTokenMissing("bearer token missing")
	ErrInvalidClaims = securityv1.ErrorAuthErrorReasonInvalidClaims("invalid bearer token")
	ErrMissingToken  = securityv1.ErrorAuthErrorReasonBearerTokenMissing("bearer token missing")
	ErrInvalidAuth   = securityv1.ErrorAuthErrorReasonUnauthenticated("unauthenticated")
)

Functions

func ClaimsFromContext added in v0.1.0

func ClaimsFromContext(ctx context.Context) security.Claims

func FromMetaData added in v0.1.0

func FromMetaData(key string) func(ctx context.Context) string

func FromTransportClient added in v0.1.0

func FromTransportClient(authorize string, scheme string) func(ctx context.Context) string

func FromTransportServer added in v0.1.0

func FromTransportServer(authorize string, scheme string) func(ctx context.Context) string

func IsSkipped added in v0.1.0

func IsSkipped(ctx context.Context, key string) bool

func NewAuthN added in v0.1.0

func NewAuthN(option *Option) (middleware.Middleware, error)

NewAuthN is a server authenticator middleware.

func NewAuthNClient added in v0.1.0

func NewAuthNClient(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)

NewAuthNClient is a client authenticator middleware.

func NewAuthNServer added in v0.1.0

func NewAuthNServer(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)

NewAuthNServer is a server authenticator middleware.

func NewAuthZServer added in v0.1.0

func NewAuthZServer(cfg *configv1.Security, ss ...OptionSetting) (middleware.Middleware, error)

NewAuthZServer returns a new server middleware.

func NewClaimsContext added in v0.1.0

func NewClaimsContext(ctx context.Context, claims security.Claims) context.Context

func NewSkipContext added in v0.1.0

func NewSkipContext(ctx context.Context) context.Context

func NewUserClaimsContext added in v0.1.0

func NewUserClaimsContext(ctx context.Context, claims security.UserClaims) context.Context

func SkipFromContext added in v0.1.0

func SkipFromContext(ctx context.Context) bool

func UserClaimsFromContext added in v0.1.0

func UserClaimsFromContext(ctx context.Context) security.UserClaims

func WithSkipContextClient added in v0.1.0

func WithSkipContextClient(ctx context.Context, key string) context.Context

func WithSkipContextServer added in v0.1.0

func WithSkipContextServer(ctx context.Context, key string) context.Context

Types

type Option added in v0.1.0

type Option struct {
	Authorizer    security.Authorizer
	Authenticator security.Authenticator
	Serializer    security.Serializer
	TokenKey      string
	SkipKey       string
	PublicPaths   []string
	TokenParser   func(ctx context.Context) string
	Skipper       func(string) bool
}

func (*Option) ApplyDefaults added in v0.1.0

func (o *Option) ApplyDefaults()

func (*Option) WithConfig added in v0.1.0

func (o *Option) WithConfig(cfg *configv1.Security) *Option

type OptionSetting added in v0.1.0

type OptionSetting = func(option *Option)

func WithAuthenticator added in v0.1.0

func WithAuthenticator(authenticator security.Authenticator) OptionSetting

func WithAuthorizer added in v0.1.0

func WithAuthorizer(authorizer security.Authorizer) OptionSetting

func WithConfig added in v0.1.0

func WithConfig(cfg *configv1.Security) OptionSetting

func WithSkipKey added in v0.1.0

func WithSkipKey(key string) OptionSetting

func WithSkipper added in v0.1.0

func WithSkipper(paths ...string) OptionSetting

func WithTokenKey added in v0.1.0

func WithTokenKey(key string) OptionSetting

type ResponseWriter added in v0.1.0

type ResponseWriter func(context.Context, security.Claims) (string, error)

type TokenParser added in v0.1.0

type TokenParser func(context.Context, string) (security.Claims, error)

Directories

Path Synopsis
authn
jwt
Package jwt implements the functions, types, and interfaces for the module.
Package jwt implements the functions, types, and interfaces for the module.
authz
casbin
Package casbin implements the functions, types, and interfaces for the module.
Package casbin implements the functions, types, and interfaces for the module.
internal
helper
Package helper implements the functions, types, and interfaces for the module.
Package helper implements the functions, types, and interfaces for the module.
model
Package model embedding the model files for Casbin.
Package model embedding the model files for Casbin.
policy
Package policy embedding the policy files for Casbin.
Package policy embedding the policy files for Casbin.

Jump to

Keyboard shortcuts

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