claims

package
v0.0.0-...-6c1d975 Latest Latest
Warning

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

Go to latest
Published: Jan 28, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetSignedToken

func GetSignedToken(opts map[string]interface{}, secret interface{}, claims UserClaims) (string, error)

GetSignedToken returns a signed JWT token based on the provided options.

func GetToken

func GetToken(method string, secret interface{}, claims UserClaims) (string, error)

GetToken returns a signed JWT token

Types

type AccessListClaim

type AccessListClaim struct {
	Paths map[string]interface{} `json:"paths,omitempty" xml:"paths" yaml:"paths,omitempty"`
}

AccessListClaim represents custom acl/paths claim

type UserClaims

type UserClaims struct {
	Audience      string           `json:"aud,omitempty" xml:"aud" yaml:"aud,omitempty"`
	ExpiresAt     int64            `json:"exp,omitempty" xml:"exp" yaml:"exp,omitempty"`
	ID            string           `json:"jti,omitempty" xml:"jti" yaml:"jti,omitempty"`
	IssuedAt      int64            `json:"iat,omitempty" xml:"iat" yaml:"iat,omitempty"`
	Issuer        string           `json:"iss,omitempty" xml:"iss" yaml:"iss,omitempty"`
	NotBefore     int64            `json:"nbf,omitempty" xml:"nbf" yaml:"nbf,omitempty"`
	Subject       string           `json:"sub,omitempty" xml:"sub" yaml:"sub,omitempty"`
	Name          string           `json:"name,omitempty" xml:"name" yaml:"name,omitempty"`
	Email         string           `json:"email,omitempty" xml:"email" yaml:"email,omitempty"`
	Roles         []string         `json:"roles,omitempty" xml:"roles" yaml:"roles,omitempty"`
	Origin        string           `json:"origin,omitempty" xml:"origin" yaml:"origin,omitempty"`
	Scope         string           `json:"scope,omitempty" xml:"scope" yaml:"scope,omitempty"`
	Organizations []string         `json:"org,omitempty" xml:"org" yaml:"org,omitempty"`
	AccessList    *AccessListClaim `json:"acl,omitempty" xml:"acl" yaml:"acl,omitempty"`
	Address       string           `json:"addr,omitempty" xml:"addr" yaml:"addr,omitempty"`
}

UserClaims represents custom and standard JWT claims.

func NewUserClaimsFromMap

func NewUserClaimsFromMap(m map[string]interface{}) (*UserClaims, error)

NewUserClaimsFromMap returns UserClaims.

func ParseClaims

func ParseClaims(token *jwtlib.Token) (*UserClaims, error)

ParseClaims extracts claims from a token.

func (UserClaims) AsMap

func (u UserClaims) AsMap() map[string]interface{}

AsMap converts UserClaims struct to dictionary.

func (*UserClaims) GetSignedToken

func (u *UserClaims) GetSignedToken(opts map[string]interface{}) (string, error)

GetSignedToken returns a signed JWT token based on the provided options.

func (*UserClaims) GetToken

func (u *UserClaims) GetToken(method string, secret interface{}) (string, error)

GetToken returns a signed JWT token

func (UserClaims) Valid

func (u UserClaims) Valid() error

Valid validates user claims.

Jump to

Keyboard shortcuts

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