| Safe Haskell | None |
|---|---|
| Language | Haskell2010 |
Web.LTI13
Description
A basic LTI 1.3 library.
It's intended to be used by implementing routes for initiate and
handleAuthResponse, and work out the associated parameters thereof.
This is written based on the LTI 1.3 specification <http://www.imsglobal.org/spec/lti/v1p3/ available from the IMS Global website>. Users will probably also find the <https://lti-ri.imsglobal.org/ LTI Reference Implementation> helpful.
Synopsis
- data Role
- data LisClaim = LisClaim {}
- data ContextClaim = ContextClaim {
- contextId :: Text
- contextLabel :: Maybe Text
- contextTitle :: Maybe Text
- data UncheckedLtiTokenClaims = UncheckedLtiTokenClaims {
- messageType :: Text
- ltiVersion :: Text
- deploymentId :: Text
- targetLinkUri :: Text
- roles :: [Role]
- email :: Maybe Text
- displayName :: Maybe Text
- firstName :: Maybe Text
- lastName :: Maybe Text
- context :: Maybe ContextClaim
- lis :: Maybe LisClaim
- newtype LtiTokenClaims = LtiTokenClaims {}
- newtype AnonymizedLtiTokenClaims = AnonymizedLtiTokenClaims UncheckedLtiTokenClaims
- anonymizeLtiTokenForLogging :: UncheckedLtiTokenClaims -> AnonymizedLtiTokenClaims
- validateLtiToken :: PlatformInfo -> IdTokenClaims UncheckedLtiTokenClaims -> Either Text (IdTokenClaims LtiTokenClaims)
- data LTI13Exception
- data PlatformInfo = PlatformInfo {}
- type Issuer = Text
- type ClientId = Text
- data SessionStore (m :: Type -> Type) = SessionStore {
- sessionStoreGenerate :: m ByteString
- sessionStoreSave :: State -> Nonce -> m ()
- sessionStoreGet :: m (Maybe State, Maybe Nonce)
- sessionStoreDelete :: m ()
- data AuthFlowConfig m = AuthFlowConfig {
- getPlatformInfo :: (Issuer, Maybe ClientId) -> m PlatformInfo
- haveSeenNonce :: Nonce -> m Bool
- myRedirectUri :: Text
- sessionStore :: SessionStore m
- type RequestParams = Map Text Text
- initiate :: MonadIO m => AuthFlowConfig m -> RequestParams -> m (Issuer, ClientId, Text)
- handleAuthResponse :: MonadIO m => Manager -> AuthFlowConfig m -> RequestParams -> PlatformInfo -> m (Text, IdTokenClaims LtiTokenClaims)
Token contents/data model
Roles in the target context (≈ course/section); see LTI spec § A.2.2 and LTI spec § 5.3.7 for details
Constructors
| Administrator | |
| ContentDeveloper | |
| Instructor | |
| Learner | |
| Mentor | |
| Other Text |
LTI spec § D LIS claim
Constructors
| LisClaim | |
Fields
| |
data ContextClaim Source #
LTI spec § 5.4.1 context claim
Constructors
| ContextClaim | |
Fields
| |
Instances
| Eq ContextClaim Source # | |
Defined in Web.LTI13 | |
| Show ContextClaim Source # | |
Defined in Web.LTI13 Methods showsPrec :: Int -> ContextClaim -> ShowS # show :: ContextClaim -> String # showList :: [ContextClaim] -> ShowS # | |
| ToJSON ContextClaim Source # | |
Defined in Web.LTI13 Methods toJSON :: ContextClaim -> Value # toEncoding :: ContextClaim -> Encoding # toJSONList :: [ContextClaim] -> Value # toEncodingList :: [ContextClaim] -> Encoding # | |
| FromJSON ContextClaim Source # | |
Defined in Web.LTI13 | |
data UncheckedLtiTokenClaims Source #
LTI specific claims on a token. You should not accept this type, and
instead prefer the newtype LtiTokenClaims which has had checking
performed on it.
Constructors
| UncheckedLtiTokenClaims | |
Fields
| |
Instances
| Eq UncheckedLtiTokenClaims Source # | |
Defined in Web.LTI13 Methods (==) :: UncheckedLtiTokenClaims -> UncheckedLtiTokenClaims -> Bool # (/=) :: UncheckedLtiTokenClaims -> UncheckedLtiTokenClaims -> Bool # | |
| Show UncheckedLtiTokenClaims Source # | |
Defined in Web.LTI13 Methods showsPrec :: Int -> UncheckedLtiTokenClaims -> ShowS # show :: UncheckedLtiTokenClaims -> String # showList :: [UncheckedLtiTokenClaims] -> ShowS # | |
| ToJSON UncheckedLtiTokenClaims Source # | |
Defined in Web.LTI13 Methods toJSON :: UncheckedLtiTokenClaims -> Value # toEncoding :: UncheckedLtiTokenClaims -> Encoding # toJSONList :: [UncheckedLtiTokenClaims] -> Value # | |
| FromJSON UncheckedLtiTokenClaims Source # | |
Defined in Web.LTI13 Methods parseJSON :: Value -> Parser UncheckedLtiTokenClaims # parseJSONList :: Value -> Parser [UncheckedLtiTokenClaims] # | |
newtype LtiTokenClaims Source #
An object representing in the type system a token whose claims have been validated.
Constructors
| LtiTokenClaims | |
Fields | |
Instances
| Eq LtiTokenClaims Source # | |
Defined in Web.LTI13 Methods (==) :: LtiTokenClaims -> LtiTokenClaims -> Bool # (/=) :: LtiTokenClaims -> LtiTokenClaims -> Bool # | |
| Show LtiTokenClaims Source # | |
Defined in Web.LTI13 Methods showsPrec :: Int -> LtiTokenClaims -> ShowS # show :: LtiTokenClaims -> String # showList :: [LtiTokenClaims] -> ShowS # | |
Anonymizing tokens for logging
newtype AnonymizedLtiTokenClaims Source #
LTI token claims from which all student data has been removed. For logging.
Constructors
| AnonymizedLtiTokenClaims UncheckedLtiTokenClaims |
Instances
| Eq AnonymizedLtiTokenClaims Source # | |
Defined in Web.LTI13 Methods (==) :: AnonymizedLtiTokenClaims -> AnonymizedLtiTokenClaims -> Bool # (/=) :: AnonymizedLtiTokenClaims -> AnonymizedLtiTokenClaims -> Bool # | |
| Show AnonymizedLtiTokenClaims Source # | |
Defined in Web.LTI13 Methods showsPrec :: Int -> AnonymizedLtiTokenClaims -> ShowS # show :: AnonymizedLtiTokenClaims -> String # showList :: [AnonymizedLtiTokenClaims] -> ShowS # | |
Validation and auth
validateLtiToken :: PlatformInfo -> IdTokenClaims UncheckedLtiTokenClaims -> Either Text (IdTokenClaims LtiTokenClaims) Source #
A direct implementation of Security § 5.1.3
data LTI13Exception Source #
(most of) the exceptions that can arise in LTI 1.3 handling. Some may have been forgotten, and this is a bug that should be fixed.
Constructors
| InvalidHandshake Text | Error in the handshake format |
| DiscoveryException Text | |
| GotHttpException HttpException | |
| InvalidLtiToken Text | Token validation error. Per Security § 5.1.3 if you get this, you should return a 401. |
Instances
| Show LTI13Exception Source # | |
Defined in Web.LTI13 Methods showsPrec :: Int -> LTI13Exception -> ShowS # show :: LTI13Exception -> String # showList :: [LTI13Exception] -> ShowS # | |
| Exception LTI13Exception Source # | |
Defined in Web.LTI13 Methods toException :: LTI13Exception -> SomeException # | |
data PlatformInfo Source #
Preregistered information about a learning platform
Constructors
| PlatformInfo | |
Fields
| |
client_id, one or more per platform; LTI spec § 3.1.3
data SessionStore (m :: Type -> Type) #
Manages state and nonce.
(Maybe OIDC should have them)
Constructors
| SessionStore | |
Fields
| |
data AuthFlowConfig m Source #
Structure you have to provide defining integration points with your app
Constructors
| AuthFlowConfig | |
Fields
| |
type RequestParams = Map Text Text Source #
Parameters to a request, either in the URL with a GET or in the body
with a POST
initiate :: MonadIO m => AuthFlowConfig m -> RequestParams -> m (Issuer, ClientId, Text) Source #
Makes the URL for IMS Security spec § 5.1.1.2 upon the § 5.1.1.1 request coming in
Returns (Issuer, RedirectURL).
handleAuthResponse :: MonadIO m => Manager -> AuthFlowConfig m -> RequestParams -> PlatformInfo -> m (Text, IdTokenClaims LtiTokenClaims) Source #
Handle the § 5.1.1.3 Step 3
response sent to the myRedirectUri
Returns (State, Token)