auth

package
v0.11.6 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2023 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	JWTAlgHS256 = "HS256"
	JWTAlgHS384 = "HS384"
	JWTAlgHS512 = "HS512"
)

Variables

This section is empty.

Functions

func GetJWTPayloadContext added in v0.11.6

func GetJWTPayloadContext(c ctx, payload interface{}) error

func JWTGuardMiddleware added in v0.9.0

func JWTGuardMiddleware(j JWT, c JWTGuardMiddlewareConfig) web.Middleware

func WithJWT added in v0.9.0

func WithJWT() plugins.Plugin

WithJWT init jwt provider

func WithOAuth

func WithOAuth() plugins.Plugin

WithOAuth init oauth providers

Types

type Code

type Code string

type ConfigJWT added in v0.9.0

type ConfigJWT struct {
	JWT []ConfigJWTItem `yaml:"jwt"`
}

ConfigJWT jwt config model

func (*ConfigJWT) Default added in v0.9.0

func (v *ConfigJWT) Default()

func (*ConfigJWT) Validate added in v0.9.0

func (v *ConfigJWT) Validate() error

type ConfigJWTItem added in v0.9.0

type ConfigJWTItem struct {
	ID        string `yaml:"id"`
	Key       string `yaml:"key"`
	Algorithm string `yaml:"alg"`
}

type ConfigOAuth

type ConfigOAuth struct {
	Providers []oauth.ConfigOAuthItem `yaml:"oauth"`
}

ConfigOAuth oauth config model

func (*ConfigOAuth) Default

func (v *ConfigOAuth) Default()

type JWT added in v0.9.0

type JWT interface {
	Sign(payload interface{}, ttl time.Duration) (string, error)
	Verify(token string, payload interface{}) (*JWTHeader, error)
}

type JWTGuardMiddlewareConfig added in v0.11.6

type JWTGuardMiddlewareConfig struct {
	AcceptHeader bool
	AcceptCookie string
}

type JWTHeader added in v0.9.0

type JWTHeader struct {
	Kid       string `json:"kid"`
	Alg       string `json:"alg"`
	IssuedAt  int64  `json:"iat"`
	ExpiresAt int64  `json:"eat"`
}

func GetJWTHeaderContext added in v0.11.6

func GetJWTHeaderContext(c ctx, payload interface{}) *JWTHeader

func (JWTHeader) MarshalEasyJSON added in v0.9.0

func (v JWTHeader) MarshalEasyJSON(w *jwriter.Writer)

MarshalEasyJSON supports easyjson.Marshaler interface

func (JWTHeader) MarshalJSON added in v0.9.0

func (v JWTHeader) MarshalJSON() ([]byte, error)

MarshalJSON supports json.Marshaler interface

func (*JWTHeader) UnmarshalEasyJSON added in v0.9.0

func (v *JWTHeader) UnmarshalEasyJSON(l *jlexer.Lexer)

UnmarshalEasyJSON supports easyjson.Unmarshaler interface

func (*JWTHeader) UnmarshalJSON added in v0.9.0

func (v *JWTHeader) UnmarshalJSON(data []byte) error

UnmarshalJSON supports json.Unmarshaler interface

type OAuth

type OAuth interface {
	RequestHandler(code string) func(web.Context)
	CallbackHandler(code string, handler func(web.Context, OAuthUser, Code)) func(web.Context)
}

type OAuthUser

type OAuthUser interface {
	GetName() string
	GetEmail() string
	GetIcon() string
}

Jump to

Keyboard shortcuts

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