Safe Haskell | None |
---|---|
Language | Haskell2010 |
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 UncheckedLtiTokenClaims
- 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)
Documentation
Roles in the target context (≈ course/section); see LTI spec § A.2.2 and LTI spec § 5.3.7 for details
LTI spec § D LIS claim
LisClaim | |
|
data ContextClaim Source #
LTI spec § 5.4.1 context claim
ContextClaim | |
|
Instances
Eq ContextClaim Source # | |
Defined in Web.LTI13 (==) :: ContextClaim -> ContextClaim -> Bool # (/=) :: ContextClaim -> ContextClaim -> Bool # | |
Show ContextClaim Source # | |
Defined in Web.LTI13 showsPrec :: Int -> ContextClaim -> ShowS # show :: ContextClaim -> String # showList :: [ContextClaim] -> ShowS # | |
ToJSON ContextClaim Source # | |
Defined in Web.LTI13 toJSON :: ContextClaim -> Value # toEncoding :: ContextClaim -> Encoding # toJSONList :: [ContextClaim] -> Value # toEncodingList :: [ContextClaim] -> Encoding # | |
FromJSON ContextClaim Source # | |
Defined in Web.LTI13 parseJSON :: Value -> Parser ContextClaim # parseJSONList :: Value -> Parser [ContextClaim] # |
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.
UncheckedLtiTokenClaims | |
|
Instances
Eq UncheckedLtiTokenClaims Source # | |
Defined in Web.LTI13 | |
Show UncheckedLtiTokenClaims Source # | |
Defined in Web.LTI13 showsPrec :: Int -> UncheckedLtiTokenClaims -> ShowS # show :: UncheckedLtiTokenClaims -> String # showList :: [UncheckedLtiTokenClaims] -> ShowS # | |
ToJSON UncheckedLtiTokenClaims Source # | |
Defined in Web.LTI13 | |
FromJSON UncheckedLtiTokenClaims Source # | |
Defined in Web.LTI13 |
newtype LtiTokenClaims Source #
An object representing in the type system a token whose claims have been validated.
Instances
Eq LtiTokenClaims Source # | |
Defined in Web.LTI13 (==) :: LtiTokenClaims -> LtiTokenClaims -> Bool # (/=) :: LtiTokenClaims -> LtiTokenClaims -> Bool # | |
Show LtiTokenClaims Source # | |
Defined in Web.LTI13 showsPrec :: Int -> LtiTokenClaims -> ShowS # show :: LtiTokenClaims -> String # showList :: [LtiTokenClaims] -> ShowS # |
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.
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 showsPrec :: Int -> LTI13Exception -> ShowS # show :: LTI13Exception -> String # showList :: [LTI13Exception] -> ShowS # | |
Exception LTI13Exception Source # | |
Defined in Web.LTI13 |
data PlatformInfo Source #
Preregistered information about a learning platform
PlatformInfo | |
|
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)
SessionStore | |
|
data AuthFlowConfig m Source #
Object you have to provide defining integration points with your app
AuthFlowConfig | |
|
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)