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.
Synopsis
- data Role
- 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
- context :: Maybe ContextClaim
- 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
Constructors
Administrator | |
ContentDeveloper | |
Instructor | |
Learner | |
Mentor | |
Other Text |
data ContextClaim Source #
LTI spec § 5.4.1 context claim
Constructors
ContextClaim | |
Fields
|
Instances
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
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 UncheckedLtiTokenClaims |
Instances
Show LtiTokenClaims Source # | |
Defined in Web.LTI13 Methods 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.
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 #
Object 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)