mytokenrepohelper

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 2024 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckMytokensAreForSameUser added in v0.6.0

func CheckMytokensAreForSameUser(rlog log.Ext1FieldLogger, tx *sqlx.Tx, a, b interface{}) (
	same bool, err error,
)

CheckMytokensAreForSameUser checks if two mytoken ids belong to the same user

func CheckTokenRevoked

func CheckTokenRevoked(rlog log.Ext1FieldLogger, tx *sqlx.Tx, id mtid.MTID, seqno uint64, rot *api.Rotation) (
	revoked bool, err error,
)

CheckTokenRevoked checks if a Mytoken has been revoked. If it is a rotating mytoken and auto_revoke is enabled for this token, it might get triggered.

func GetMTName added in v0.4.0

func GetMTName(rlog log.Ext1FieldLogger, tx *sqlx.Tx, id mtid.MTID) (name db.NullString, err error)

GetMTName returns the name of the mytoken

func GetTokenUsagesAT

func GetTokenUsagesAT(rlog log.Ext1FieldLogger, tx *sqlx.Tx, myID mtid.MTID, restrictionHash string) (
	usages *int64, err error,
)

GetTokenUsagesAT returns how often a Mytoken was used with a specific restriction to obtain an access token

func GetTokenUsagesOther

func GetTokenUsagesOther(rlog log.Ext1FieldLogger, tx *sqlx.Tx, myID mtid.MTID, restrictionHash string) (
	usages *int64, err error,
)

GetTokenUsagesOther returns how often a Mytoken was used with a specific restriction to do something else than obtaining an access token

func IncreaseTokenUsageAT

func IncreaseTokenUsageAT(rlog log.Ext1FieldLogger, tx *sqlx.Tx, myID mtid.MTID, jsonRestriction []byte) error

IncreaseTokenUsageAT increases the usage count for obtaining ATs with a Mytoken and the given restriction

func IncreaseTokenUsageOther

func IncreaseTokenUsageOther(rlog log.Ext1FieldLogger, tx *sqlx.Tx, myID mtid.MTID, jsonRestriction []byte) error

IncreaseTokenUsageOther increases the usage count for other usages with a Mytoken and the given restriction

func MOMIDHasParent added in v0.10.0

func MOMIDHasParent(rlog log.Ext1FieldLogger, tx *sqlx.Tx, momID string, parent mtid.MTID) (
	isParent bool, err error,
)

MOMIDHasParent checks if the token for a revocation id is a child of the (potential) parent mytoken

func RevokeMT

func RevokeMT(rlog log.Ext1FieldLogger, tx *sqlx.Tx, id interface{}, recursive bool) error

RevokeMT revokes the passed mytoken and depending on the recursive parameter also its children

func SetMetadata added in v0.10.0

func SetMetadata(
	rlog log.Ext1FieldLogger, tx *sqlx.Tx, id mtid.MTID, meta MytokenDBMetadata,
) error

SetMetadata adds a mytoken's metadata (capabilities, rotation, restrictions) to the database. This is needed for legacy mytokens where the metadata was not yet stored on creation. token version <0.7

func UpdateSeqNo added in v0.3.0

func UpdateSeqNo(rlog log.Ext1FieldLogger, tx *sqlx.Tx, id mtid.MTID, seqno uint64) error

UpdateSeqNo updates the sequence number of a mytoken, i.e. it rotates the mytoken. Don't forget to update the encryption key

Types

type MytokenDBMetadata added in v0.10.0

type MytokenDBMetadata struct {
	Capabilities db.NullString
	Rotation     db.NullString
	Restrictions db.NullString
}

MytokenDBMetadata is a type for metadata about a mytoken

Jump to

Keyboard shortcuts

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