auth

package
v0.0.0-...-cb66316 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2022 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidAuthToken = errors.New("invalid authentication token")
)

Functions

func NewEnforcer

func NewEnforcer(r io.Reader, a persist.Adapter) (*casbin.Enforcer, error)

Types

type Authenticator

type Authenticator interface {
	Authenticate(r *http.Request) (string, error)
	GetAccessToken(u string) (string, error)
}

func New

type AuthenticatorConfig

type AuthenticatorConfig struct {
	// When set it uses JWT authentication
	JwtSignKey          string
	AccessTokenDuration time.Duration
	Issuer              string
	// Log
	Log zerolog.Logger
}

type Authorizator

type Authorizator interface {
	//Authorize(identity any, r *http.Request) error
	HasPermission(identity any, action string, asset string) error
}

func NewAuthorizator

func NewAuthorizator(cfg AuthorizatorConfig) (Authorizator, error)

type AuthorizatorConfig

type AuthorizatorConfig struct {
	CasbinModelReader io.Reader
	CasbinAdapter     persist.Adapter
	Log               zerolog.Logger
}

type JwtClaims

type JwtClaims struct {
	User  string                 `json:"user`
	Extra map[string]interface{} `json:"extra,omitempty"`
	jwt.StandardClaims
}

Jump to

Keyboard shortcuts

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