auth

package
v0.0.0-...-dec19c8 Latest Latest
Warning

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

Go to latest
Published: May 17, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Auth

type Auth struct {
	// contains filtered or unexported fields
}

Auth us an authenticator that can 1) Issue jwt token for user or service 2) Create echo jwt middleware for jwt validation.

func NewAuth

func NewAuth(cfg *Config) (*Auth, error)

func (*Auth) CookieForUser

func (a *Auth) CookieForUser(user *model.User) (*http.Cookie, error)

func (*Auth) EchoAuthServiceSide

func (a *Auth) EchoAuthServiceSide() echo.MiddlewareFunc

func (*Auth) EchoAuthUserSide

func (a *Auth) EchoAuthUserSide() echo.MiddlewareFunc

func (*Auth) GRPCAuthFunc

func (a *Auth) GRPCAuthFunc(ctx context.Context) (context.Context, error)

func (*Auth) NewTokenForService

func (a *Auth) NewTokenForService(name string) (string, error)

func (*Auth) NewTokenForUser

func (a *Auth) NewTokenForUser(user *model.User) (string, error)

type Claims

type Claims struct {
	UserID string `json:"uid"`
	Name   string `json:"name"`
	Role   string `json:"role,omitempty"`
	jwt.RegisteredClaims
}

func GetClaimFromEchoContext

func GetClaimFromEchoContext(c echo.Context) (*Claims, error)

func GetClaimsFromContext

func GetClaimsFromContext(ctx context.Context) (*Claims, bool)

func (*Claims) IsService

func (c *Claims) IsService() bool

type Config

type Config struct {
	Secret       string
	Domain       string
	SecureCookie bool
	Expiration   time.Duration
}

Jump to

Keyboard shortcuts

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