datastore

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

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

Go to latest
Published: Aug 20, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Overview

Package datastore implements the interfaces and types for all the different storers used in LTI.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrRegistrationNotFound is the error returned when a registration cannot be found.
	ErrRegistrationNotFound = errors.New("registration not found")

	// ErrDeploymentNotFound is the error returned when an issuer/deploymentID cannot be found.
	ErrDeploymentNotFound = errors.New("deployment not found")
)
View Source
var (
	// ErrNonceNotFound is the error returned when a nonce cannot be found.
	ErrNonceNotFound = errors.New("nonce not found")

	// ErrNonceTargetLinkURIMismatch is the error returned when a nonce is found but there's a mismatch in the
	// target URI.
	ErrNonceTargetLinkURIMismatch = errors.New("nonce found with mismatched target link uri")
)
View Source
var ErrAccessTokenExpired = errors.New("access token has expired")

ErrAccessTokenExpired is the error returned when an access token has expired.

View Source
var ErrAccessTokenNotFound = errors.New("access token not found")

ErrAccessTokenNotFound is the error returned when an access token cannot be found.

View Source
var ErrLaunchDataNotFound = errors.New("launch data not found")

ErrLaunchDataNotFound is the error returned when cached launch data cannot be found.

Functions

func ValidateDeploymentID

func ValidateDeploymentID(deploymentID string) error

ValidateDeploymentID validates a deployment ID.

Types

type AccessToken

type AccessToken struct {
	TokenURI   string    `json:"tokenURI"`
	ClientID   string    `json:"clientID"`
	Scopes     []string  `json:"scopes"`
	Token      string    `json:"token"`
	ExpiryTime time.Time `json:"expiryTime"`
}

An AccessToken is the scoped bearer token used for direct communication between the platform and tool.

type AccessTokenStorer

type AccessTokenStorer interface {
	// StoreAccessToken stores an access token.
	StoreAccessToken(token AccessToken) error

	// FindAccessToken retrieves a previously-stored access token. If the access token cannot be found, it returns
	// ErrAccessTokenNotFound.
	FindAccessToken(tokenURI, clientID string, scopes []string) (AccessToken, error)
}

An AccessTokenStorer manages the storage and retrieval of access tokens.

type Config

type Config struct {
	Registrations RegistrationStorer
	Nonces        NonceStorer
	LaunchData    LaunchDataStorer
	AccessTokens  AccessTokenStorer
}

Config holds the stores required for LTI packages. New package functions will accept the zero value of this struct, and in the case of the zero value, the resulting LTI process will use nonpersistent storage.

type Deployment

type Deployment struct {
	DeploymentID string
}

A Deployment contains that details that identify the platform-tool integration for a message. Source: http://www.imsglobal.org/spec/lti/v1p3/#lti-deployment-id-claim.

type LaunchDataStorer

type LaunchDataStorer interface {
	// StoreLaunchData stores the JSON launch data associated with the supplied launch ID.
	StoreLaunchData(launchID string, launchData json.RawMessage) error

	// FindLaunchData retrieves previously-stored launch data using the `launchID'. If the launch data cannot be
	// found, it returns ErrLaunchDataNotFound.
	FindLaunchData(launchID string) (json.RawMessage, error)
}

A LaunchDataStorer manages the storage and retrieval of LTI launch data.

type NonceStorer

type NonceStorer interface {
	// StoreNonce stores a nonce for later retrieval.
	StoreNonce(nonce string, targetLinkURI string) error

	// TestAndClearNonce tests for the existance of a nonce. If the nonce is found and the target URI matches, it
	// removes/clears the nonce and returns nil. Otherwise, it returns one of the ErrNonce errors.
	TestAndClearNonce(nonce string, targetLinkURI string) error
}

A NonceStorer manages the storage and retrieval of LTI nonces.

type Registration

type Registration struct {
	Issuer        string
	ClientID      string
	AuthTokenURI  *url.URL
	AuthLoginURI  *url.URL
	KeysetURI     *url.URL
	TargetLinkURI *url.URL
}

A Registration is the details of a link between a Platform and a Tool. There can be multiple deployments per registration. Each Registration is uniquely identified by the ClientID.

type RegistrationStorer

type RegistrationStorer interface {
	// StoreRegistration stores a registration for later retrieval.
	StoreRegistration(Registration) error

	// FindRegistrationByIssuerAndClientID retrieves a previously-stored registration using the `issuer' and
	// `clientID' fields. If the registration cannot be found, it returns ErrRegistrationNotFound.
	FindRegistrationByIssuerAndClientID(issuer string, clientID string) (Registration, error)

	// StoreDeployment stores a deployment for later retrieval.
	StoreDeployment(issuer string, deployment Deployment) error

	// FindDeployment retrieves a previously-stored deployment using the `issuer' and `deploymentID'. Its primary
	// purpose is to validate the supplied deployment ID. If the deployment cannot be found, it returns
	// ErrDeploymentNotFound.
	FindDeployment(issuer string, deploymentID string) (Deployment, error)
}

A RegistrationStorer manages the storage and retrieval of LTI registrations & deployments.

Directories

Path Synopsis
Package nonpersistent implements an in-memory (non-persistent) data store.
Package nonpersistent implements an in-memory (non-persistent) data store.
Package sql implements a persistent SQL data store.
Package sql implements a persistent SQL data store.

Jump to

Keyboard shortcuts

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