mytoken

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Sep 21, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CreateTransferCode

func CreateTransferCode(myID mtid.MTID, jwt string, newMT bool, responseType model.ResponseType, clientMetaData api.ClientMetaData) (string, uint64, error)

CreateTransferCode creates a transfer code for the passed mytoken id

Types

type Mytoken

type Mytoken struct {
	// On update also update api.Mytoken
	Version              api.TokenVersion          `json:"ver"`
	TokenType            string                    `json:"token_type"`
	Issuer               string                    `json:"iss"`
	Subject              string                    `json:"sub"`
	ExpiresAt            unixtime.UnixTime         `json:"exp,omitempty"`
	NotBefore            unixtime.UnixTime         `json:"nbf"`
	IssuedAt             unixtime.UnixTime         `json:"iat"`
	ID                   mtid.MTID                 `json:"jti"`
	SeqNo                uint64                    `json:"seq_no"`
	Audience             string                    `json:"aud"`
	OIDCSubject          string                    `json:"oidc_sub"`
	OIDCIssuer           string                    `json:"oidc_iss"`
	Restrictions         restrictions.Restrictions `json:"restrictions,omitempty"`
	Capabilities         api.Capabilities          `json:"capabilities"`
	SubtokenCapabilities api.Capabilities          `json:"subtoken_capabilities,omitempty"`
	Rotation             *api.Rotation             `json:"rotation,omitempty"`
	// contains filtered or unexported fields
}

Mytoken is a mytoken Mytoken

func NewMytoken

func NewMytoken(oidcSub, oidcIss string, r restrictions.Restrictions, c, sc api.Capabilities, rot *api.Rotation) *Mytoken

NewMytoken creates a new Mytoken

func ParseJWT

func ParseJWT(token string) (*Mytoken, error)

ParseJWT parses a token string into a Mytoken

func (*Mytoken) ExpiresIn

func (mt *Mytoken) ExpiresIn() uint64

ExpiresIn returns the amount of seconds in which this token expires

func (Mytoken) Rotate added in v0.3.0

func (mt Mytoken) Rotate() *Mytoken

Rotate returns a Mytoken and returns the new *Mytoken

func (*Mytoken) ToJWT

func (mt *Mytoken) ToJWT() (string, error)

ToJWT returns the Mytoken as JWT

func (*Mytoken) ToTokenResponse

func (mt *Mytoken) ToTokenResponse(responseType model.ResponseType, maxTokenLen int, networkData api.ClientMetaData, jwt string) (response.MytokenResponse, error)

ToTokenResponse creates a MytokenResponse for this Mytoken according to the passed model.ResponseType

func (*Mytoken) ToUsedMytoken

func (mt *Mytoken) ToUsedMytoken(tx *sqlx.Tx) (*UsedMytoken, error)

ToUsedMytoken turns a Mytoken into a UsedMytoken by adding information about its usages

func (*Mytoken) Valid

func (mt *Mytoken) Valid() error

Valid checks if this Mytoken is valid

func (*Mytoken) VerifyCapabilities

func (mt *Mytoken) VerifyCapabilities(required ...api.Capability) bool

VerifyCapabilities verifies that this Mytoken has the required capabilities

type UsedMytoken

type UsedMytoken struct {
	Mytoken
	Restrictions []restrictions.UsedRestriction `json:"restrictions,omitempty"`
}

UsedMytoken is a type for a Mytoken that has been used, it additionally has information how often it has been used

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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