authentication

package
v1.1.0-rc.1 Latest Latest
Warning

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

Go to latest
Published: May 8, 2024 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthNone = "none"
	AuthJWT  = "jwt"
)
View Source
const (
	JWTContextKey = "jwt"
)

Variables

View Source
var (
	ErrJWTInvalidClaims = echo.NewHTTPError(http.StatusUnauthorized, "invalid jwt claims")
	ErrInvalidJWT       = echo.NewHTTPError(http.StatusUnauthorized, "token is invalid")
)

Errors

View Source
var DefaultJWTDuration time.Duration

Functions

func AddAuthentication

func AddAuthentication(
	apiRoot echoswagger.ApiRoot,
	userManager *users.UserManager,
	nodeIdentityProvider registry.NodeIdentityProvider,
	authConfig AuthConfiguration,
	mocker interfaces.Mocker,
) echo.MiddlewareFunc

func GetNoneAuthMiddleware added in v1.0.3

func GetNoneAuthMiddleware() echo.MiddlewareFunc

func ValidatePermissions added in v1.0.3

func ValidatePermissions(permissions []string) func(next echo.HandlerFunc) echo.HandlerFunc

Types

type AuthConfiguration

type AuthConfiguration struct {
	Scheme string `default:"ip" usage:"selects which authentication to choose"`

	JWTConfig JWTAuthConfiguration `name:"jwt" usage:"defines the jwt configuration"`
}

type AuthContext

type AuthContext struct {
	echo.Context
	// contains filtered or unexported fields
}

func (*AuthContext) Name added in v1.0.3

func (a *AuthContext) Name() string

func (*AuthContext) Scheme

func (a *AuthContext) Scheme() string

type AuthHandler

type AuthHandler struct {
	Jwt         *JWTAuth
	UserManager *users.UserManager
}

func (*AuthHandler) JWTLoginHandler added in v1.0.3

func (a *AuthHandler) JWTLoginHandler(c echo.Context) error

type JWTAuth

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

func GetJWTAuthMiddleware added in v1.0.3

func GetJWTAuthMiddleware(
	config JWTAuthConfiguration,
	nodeIDKeypair *cryptolib.KeyPair,
	userManager *users.UserManager,
) (*JWTAuth, echo.MiddlewareFunc)

func NewJWTAuth

func NewJWTAuth(duration time.Duration, nodeIDKeypair *cryptolib.KeyPair) *JWTAuth

func (*JWTAuth) IssueJWT

func (j *JWTAuth) IssueJWT(username string, claims *WaspClaims) (string, error)

type JWTAuthConfiguration

type JWTAuthConfiguration struct {
	Duration time.Duration `default:"24h" usage:"jwt token lifetime"`
}

type ValidationError added in v1.0.3

type ValidationError struct {
	MissingPermission string `json:"missingPermission" swagger:"required"`
	Error             string `json:"error" swagger:"required"`
}

type WaspClaims

type WaspClaims struct {
	jwt.RegisteredClaims
	Permissions map[string]struct{} `json:"permissions"`
}

func (*WaspClaims) HasPermission

func (c *WaspClaims) HasPermission(permission string) bool

func (*WaspClaims) VerifySubject

func (c *WaspClaims) VerifySubject(expected string) bool

type WebAPI

type WebAPI interface {
	GET(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	POST(path string, h echo.HandlerFunc, m ...echo.MiddlewareFunc) *echo.Route
	Use(middleware ...echo.MiddlewareFunc)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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