transfercoderepo

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2021 License: MIT Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DeleteTransferCodeByState

func DeleteTransferCodeByState(tx *sqlx.Tx, state *state.State) error

DeleteTransferCodeByState deletes a polling code

func LinkPollingCodeToST

func LinkPollingCodeToST(tx *sqlx.Tx, pollingCode, jwt string) error

LinkPollingCodeToST links a pollingCode to a SuperToken

func PopTokenForTransferCode

func PopTokenForTransferCode(tx *sqlx.Tx, pollingCode string) (jwt string, err error)

PopTokenForTransferCode returns the decrypted token for a polling code and then deletes the entry

Types

type ShortToken

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

ShortToken holds database information of a short token

func NewShortToken

func NewShortToken(jwt string) (*ShortToken, error)

NewShortToken creates a new short token from the given jwt of a normal SuperToken

func ParseShortToken

func ParseShortToken(token string) *ShortToken

ParseShortToken creates a new short token from a short token string

func (ShortToken) Delete

func (pt ShortToken) Delete(tx *sqlx.Tx) error

Delete deletes the proxyToken from the database, it does not delete the linked SuperToken, the jwt should have been retrieved earlier and the SuperToken if desired be revoked separately

func (*ShortToken) ID

func (pt *ShortToken) ID() string

ID returns the id of this token

func (*ShortToken) JWT

func (pt *ShortToken) JWT(tx *sqlx.Tx) (jwt string, valid bool, err error)

JWT returns the decrypted jwt that is linked to this proxyToken

func (*ShortToken) SetJWT

func (pt *ShortToken) SetJWT(jwt string) (err error)

SetJWT sets the jwt for this proxyToken

func (ShortToken) Store

func (pt ShortToken) Store(tx *sqlx.Tx) error

Store stores the proxyToken

func (ShortToken) String

func (pt ShortToken) String() string

func (ShortToken) Token

func (pt ShortToken) Token() string

Token returns the token of this proxyToken

func (ShortToken) Update

func (pt ShortToken) Update(tx *sqlx.Tx) error

Update updates the jwt of the proxyToken

type TransferCode

type TransferCode struct {
	Attributes transferCodeAttributes
	// contains filtered or unexported fields
}

TransferCode is a type used to transfer a token

func CreatePollingCode

func CreatePollingCode(pollingCode string, responseType model.ResponseType, redirectLink string) *TransferCode

CreatePollingCode creates a polling code

func NewTransferCode

func NewTransferCode(jwt string, newST bool, responseType model.ResponseType) (*TransferCode, error)

NewTransferCode creates a new TransferCode for the passed jwt

func ParseTransferCode

func ParseTransferCode(token string) *TransferCode

ParseTransferCode creates a new transfer code from a transfer code string

func (TransferCode) Delete

func (pt TransferCode) Delete(tx *sqlx.Tx) error

Delete deletes the proxyToken from the database, it does not delete the linked SuperToken, the jwt should have been retrieved earlier and the SuperToken if desired be revoked separately

func (TransferCode) GetRevokeJWT

func (tc TransferCode) GetRevokeJWT(tx *sqlx.Tx) (bool, error)

GetRevokeJWT returns a bool indicating if the linked jwt should also be revoked when this TransferCode is revoked or not

func (*TransferCode) ID

func (pt *TransferCode) ID() string

ID returns the id of this token

func (*TransferCode) JWT

func (pt *TransferCode) JWT(tx *sqlx.Tx) (jwt string, valid bool, err error)

JWT returns the decrypted jwt that is linked to this proxyToken

func (*TransferCode) SetJWT

func (pt *TransferCode) SetJWT(jwt string) (err error)

SetJWT sets the jwt for this proxyToken

func (TransferCode) Store

func (tc TransferCode) Store(tx *sqlx.Tx) error

Store stores the TransferCode in the database

func (TransferCode) String

func (pt TransferCode) String() string

func (TransferCode) Token

func (pt TransferCode) Token() string

Token returns the token of this proxyToken

func (TransferCode) Update

func (pt TransferCode) Update(tx *sqlx.Tx) error

Update updates the jwt of the proxyToken

type TransferCodeStatus

type TransferCodeStatus struct {
	Found        bool               `db:"found"`
	Expired      bool               `db:"expired"`
	ResponseType model.ResponseType `db:"response_type"`
	RedirectURL  sql.NullString     `db:"redirect"`
}

TransferCodeStatus holds information about the status of a polling code

func CheckTransferCode

func CheckTransferCode(tx *sqlx.Tx, pollingCode string) (TransferCodeStatus, error)

CheckTransferCode checks the passed polling code in the database

Jump to

Keyboard shortcuts

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