auth

package
v0.0.0-...-e612854 Latest Latest
Warning

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

Go to latest
Published: Feb 14, 2022 License: LGPL-2.1 Imports: 9 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetUserIDFromContext

func GetUserIDFromContext(r *http.Request) (string, error)

Types

type AuthMiddleware

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

func NewAuthMiddleware

func NewAuthMiddleware(jwtConf *JWTConfig) *AuthMiddleware

func (*AuthMiddleware) CheckAuth

func (am *AuthMiddleware) CheckAuth(next http.Handler) http.Handler

func (*AuthMiddleware) RequireAuth

func (am *AuthMiddleware) RequireAuth(next http.Handler) http.Handler

type JWTConfig

type JWTConfig struct {
	Secret        string
	ExpirySeconds int32
	Aud           string
}

type JWTUtil

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

func NewJWTUtil

func NewJWTUtil(conf *JWTConfig) *JWTUtil

func (*JWTUtil) GenerateAccessToken

func (jwu *JWTUtil) GenerateAccessToken(user_id string) (string, error)

func (*JWTUtil) GetUserIDFromJWT

func (jwu *JWTUtil) GetUserIDFromJWT(r *http.Request) (string, error)

func (*JWTUtil) ParseJWTClaims

func (jwu *JWTUtil) ParseJWTClaims(bearer string) (*jwt.StandardClaims, error)

type UserIDKeyType

type UserIDKeyType string

UserIDKeyType is the key type for setting the context and to avoid collisions

const (
	//UserIDKey is the key used to set the context value for User ID
	UserIDKey UserIDKeyType = "SimUserID"
)

Jump to

Keyboard shortcuts

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