nonpersistent

package
v0.0.0-...-21c0a40 Latest Latest
Warning

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

Go to latest
Published: May 22, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package nonpersistent implements an in-memory (non-persistent) data store. It implements all of the Storer interfaces, so it can be used for any and all LTI data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Store

type Store struct {
	Registrations *sync.Map
	Deployments   *sync.Map
	Nonces        *sync.Map
	LaunchData    *sync.Map
	AccessTokens  *sync.Map
}

Store implements an in-memory datastore.

var DefaultStore *Store = New()

DefaultStore provides a single default datastore as a package variable so that other LTI functions can fall back on this datastore whenever the user does not explicitly specify a datastore.

func New

func New() *Store

New returns an empty, zeroed sync.Map for each Storer interface.

func (*Store) FindAccessToken

func (s *Store) FindAccessToken(tokenURI, clientID string, scopes []string) (datastore.AccessToken, error)

FindAccessToken retrieves bearer tokens for potential reuse.

func (*Store) FindDeployment

func (s *Store) FindDeployment(issuer, deploymentID string) (datastore.Deployment, error)

FindDeployment looks up and returns either a Deployment by the issuer and deployment ID or the datastore error ErrDeploymentNotFound.

func (*Store) FindLaunchData

func (s *Store) FindLaunchData(launchID string) (json.RawMessage, error)

FindLaunchData retrieves a cached launchData.

func (*Store) FindRegistrationByIssuerAndClientID

func (s *Store) FindRegistrationByIssuerAndClientID(issuer, clientID string) (datastore.Registration, error)

FindRegistrationByIssuerAndClientID looks up and returns either a Registration by the issuer or the datastore error ErrRegistrationNotFound.

func (*Store) StoreAccessToken

func (s *Store) StoreAccessToken(token datastore.AccessToken) error

StoreAccessToken stores bearer tokens for potential reuse.

func (*Store) StoreDeployment

func (s *Store) StoreDeployment(issuer string, d datastore.Deployment) error

StoreDeployment stores a deployment ID in-memory.

func (*Store) StoreLaunchData

func (s *Store) StoreLaunchData(launchID string, launchData json.RawMessage) error

StoreLaunchData stores the launch data, i.e. the id_token JWT.

func (*Store) StoreNonce

func (s *Store) StoreNonce(nonce, targetLinkURI string) error

StoreNonce stores a Nonce in-memory. Since the nonce and target_link_uri values have similarly scoped verifications required, use the the unique nonce value as a key to store the target_link_uri value. This is used to verify the OIDC login request target_link_uri is the same as the claim of the same name in the launch id_token.

func (*Store) StoreRegistration

func (s *Store) StoreRegistration(reg datastore.Registration) error

StoreRegistration stores a Registration in-memory.

func (*Store) TestAndClearNonce

func (s *Store) TestAndClearNonce(nonce, targetLinkURI string) error

TestAndClearNonce looks up a nonce, clears the entry if found, and returns whether it was found via the error return. If the nonce wasn't found, it returns the datastore error ErrNonceNotFound. If it was found, it returns nil.

Jump to

Keyboard shortcuts

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