jwt

package
v0.0.1-rc7 Latest Latest
Warning

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

Go to latest
Published: Jan 22, 2024 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthorizationHeaderName = "Authorization"
	BearerTokenPrefix       = "Bearer "
)
View Source
const (
	UserDIDClaimName             = "sub"
	ExpirationTimestampClaimName = "exp"
	RoleClaimName                = "role"
	GroupClaimName               = "group"
	OrgDIDClaimName              = "org"
	TokenTypeClaimName           = "type"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthClaim

type AuthClaim struct {
	OrgDID  string
	UserDID string
	Role    uint32
	Group   *uuid.UUID
	Type    TokenType
}

AuthClaim is a helper structure to organize all claims in one entity

type JWTConfig

type JWTConfig struct {
	SecretKey             string        `fig:"secret_key,required"`
	AccessExpirationTime  time.Duration `fig:"access_expiration_time,required"`
	RefreshExpirationTime time.Duration `fig:"refresh_expiration_time,required"`
}

type JWTIssuer

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

func (*JWTIssuer) IssueJWT

func (i *JWTIssuer) IssueJWT(claim *AuthClaim) (string, error)

func (*JWTIssuer) ValidateJWT

func (i *JWTIssuer) ValidateJWT(str string) (claim *AuthClaim, err error)

type Jwter

type Jwter interface {
	JWT() *JWTIssuer
}

func NewJwter

func NewJwter(getter kv.Getter) Jwter

type RawJWT

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

RawJWT represents helper structure to provide setter and getter methods to work with JWT claims

func (*RawJWT) DID

func (r *RawJWT) DID() (res string, ok bool)

func (*RawJWT) Group

func (r *RawJWT) Group() *uuid.UUID

func (*RawJWT) OrgDID

func (r *RawJWT) OrgDID() (did string, ok bool)

func (*RawJWT) Role

func (r *RawJWT) Role() (role uint32, ok bool)

func (*RawJWT) SetDID

func (r *RawJWT) SetDID(did string) *RawJWT

func (*RawJWT) SetExpirationTimestamp

func (r *RawJWT) SetExpirationTimestamp(expiration time.Duration) *RawJWT

func (*RawJWT) SetGroup

func (r *RawJWT) SetGroup(group *uuid.UUID) *RawJWT

func (*RawJWT) SetOrgDID

func (r *RawJWT) SetOrgDID(org string) *RawJWT

func (*RawJWT) SetRole

func (r *RawJWT) SetRole(role uint32) *RawJWT

func (*RawJWT) SetTokenAccess

func (r *RawJWT) SetTokenAccess() *RawJWT

func (*RawJWT) SetTokenRefresh

func (r *RawJWT) SetTokenRefresh() *RawJWT

func (*RawJWT) TokenType

func (r *RawJWT) TokenType() (typ TokenType, ok bool)

type TokenType

type TokenType string
var (
	AccessTokenType  TokenType = "access"
	RefreshTokenType TokenType = "refresh"
)

Jump to

Keyboard shortcuts

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