auth

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2022 License: BSD-3-Clause Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const Algorithm = jwa.PS256
View Source
const (
	XBridgeAuthorizationHeaderKey = "X-Bridge-Authorization"
)

Variables

This section is empty.

Functions

func CreateJWTWithUser

func CreateJWTWithUser(user User, privateKey interface{}) (string, error)

func GetJWKKeys

func GetJWKKeys() (jwk.Key, jwk.Key, error)

func GetPrivateJWK

func GetPrivateJWK() (jwk.Key, error)

func Middleware

func Middleware(c *MiddlewareConfig) bridgehttp.Middleware

Middleware is a middleware to handle authn and authz

Types

type CreateJWTResult

type CreateJWTResult struct {
	Token        string
	IssuedAt     time.Time
	ExpireIn     time.Duration
	PublicKeySet jwk.Set
}

CreateJWTResult is a result of CreateJWT

func CreateJWT

func CreateJWT(user User) (*CreateJWTResult, error)

CreateJWT creates a jwt for testing uid means user ID

type MiddlewareConfig

type MiddlewareConfig struct {
	TenantID string
	Logger   logr.Logger
	PublicKeyGetter

	// RegisterUserObject is an optional
	RegisterUserObject TenantIDGetter
}

MiddlewareConfig is a config for Middleware function.

type PublicKeyGetter

type PublicKeyGetter interface {
	GetPublicKey() jwk.Set
}

PublicKeyGetter is getter of public jwk.

type StaticPublicKeyGetter

type StaticPublicKeyGetter struct {
	PublicKey jwk.Set
}

StaticPublicKeyGetter is public key getter as static

func (*StaticPublicKeyGetter) GetPublicKey

func (s *StaticPublicKeyGetter) GetPublicKey() jwk.Set

type Tenant

type Tenant struct {
	ID string `json:"id"`
}

Tenant is included in payload of the jwt which is coming from basemachina API.

type TenantIDGetter

type TenantIDGetter interface {
	GetTenantID() string
}

TenantIDGetter is getter of tenant ID.

type User

type User struct {
	Tenant Tenant `json:"tenant"`
}

User is included in payload of the jwt which is coming from basemachina API.

func (User) GetTenantID

func (u User) GetTenantID() string

Jump to

Keyboard shortcuts

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