auth

package
v0.11.4 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 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 GetJWTPayload added in v0.9.0

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

func JWTGuardMiddleware added in v0.9.0

func JWTGuardMiddleware(j JWT) 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 {
	Key       string        `yaml:"key"`
	TTL       time.Duration `yaml:"ttl"`
	Algorithm string        `yaml:"alg"`
	Cookie    string        `yaml:"cookie"`
}

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{}) (string, error)
	Extend(token string) (string, error)
	Verify(token string, payload interface{}) (*JWTHeader, error)
	CookieName() string
}

type JWTHeader added in v0.9.0

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

func GetJWTHeader added in v0.9.0

func GetJWTHeader(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