Safe Haskell | None |
---|---|
Language | Haskell2010 |
This is an implementation of git@github.com:liqdadhocracy3.git:docssourceapi/authentication_api.rst
- data A3Resource a = A3Resource {
- mPath :: Maybe Path
- mContentType :: Maybe ContentType
- mData :: Maybe a
- newtype A3UserNoPass = A3UserNoPass {}
- newtype A3UserWithPass = A3UserWithPass {}
- data ActivationRequest = ActivationRequest ConfirmationToken
- type Api = ThentosApi :<|> (("js" :> Api) :<|> ServiceProxy)
- data ContentType = CTUser
- data LoginRequest
- data PasswordResetRequest = PasswordResetRequest Path UserPass
- newtype Path = Path {
- fromPath :: ST
- data RequestResult
- type ThentosApi = ("principals" :> ("users" :> (ReqBody `[JSON]` A3UserWithPass :> Post200 `[JSON]` TypedPathWithCacheControl))) :<|> (("activate_account" :> (ReqBody `[JSON]` ActivationRequest :> Post200 `[JSON]` RequestResult)) :<|> (("login_username" :> (ReqBody `[JSON]` LoginRequest :> Post200 `[JSON]` RequestResult)) :<|> (("login_email" :> (ReqBody `[JSON]` LoginRequest :> Post200 `[JSON]` RequestResult)) :<|> ("password_reset" :> (ReqBody `[JSON]` PasswordResetRequest :> Post200 `[JSON]` RequestResult)))))
- data TypedPath = TypedPath {}
- data TypedPathWithCacheControl = TypedPathWithCacheControl {
- tpccTypedPath :: TypedPath
- tpccChangedDescendants :: [Path]
- tpccCreated :: [Path]
- tpccModified :: [Path]
- tpccRemoved :: [Path]
- a3corsPolicy :: CorsPolicy
- a3ProxyAdapter :: ProxyAdapter ThentosA3Error
- runBackend :: HttpConfig -> ActionState -> IO ()
- serveApi :: Manager -> HttpConfig -> ActionState -> Application
- thentosApi :: ActionState -> Server ThentosApi
Documentation
data A3Resource a
A3Resource | |
|
Eq a => Eq (A3Resource a) | |
Show a => Show (A3Resource a) | |
Generic (A3Resource a) | |
ToSample a => ToSample (A3Resource a) | |
ToJSON a => ToJSON (A3Resource a) | |
FromJSON a => FromJSON (A3Resource a) | |
type Rep (A3Resource a) |
newtype A3UserNoPass
Eq A3UserNoPass | |
Generic A3UserNoPass | |
ToSample A3UserNoPass | |
ToJSON A3UserNoPass | |
FromJSON A3UserNoPass | |
type Rep A3UserNoPass |
newtype A3UserWithPass
Eq A3UserWithPass | |
Generic A3UserWithPass | |
ToSample A3UserWithPass | |
ToJSON A3UserWithPass | |
FromJSON A3UserWithPass | |
HasDocExtras (RestDocs Api) | |
type Rep A3UserWithPass |
data ActivationRequest
Eq ActivationRequest | |
Show ActivationRequest | |
Generic ActivationRequest | |
ToSample ActivationRequest | |
ToJSON ActivationRequest | |
FromJSON ActivationRequest | |
HasDocExtras (RestDocs Api) | |
type Rep ActivationRequest |
type Api = ThentosApi :<|> (("js" :> Api) :<|> ServiceProxy)
data ContentType
Bounded ContentType | |
Enum ContentType | |
Eq ContentType | |
Ord ContentType | |
Read ContentType | |
Show ContentType | |
Generic ContentType | |
ToSample ContentType | |
ToJSON ContentType | |
FromJSON ContentType | |
type Rep ContentType |
data LoginRequest
Eq LoginRequest | |
Generic LoginRequest | |
ToSample LoginRequest | |
ToJSON LoginRequest | |
FromJSON LoginRequest | |
HasDocExtras (RestDocs Api) | |
type Rep LoginRequest |
data PasswordResetRequest
Eq PasswordResetRequest | |
Generic PasswordResetRequest | |
ToSample PasswordResetRequest | |
ToJSON PasswordResetRequest | |
FromJSON PasswordResetRequest | |
HasDocExtras (RestDocs Api) | |
type Rep PasswordResetRequest |
newtype Path
data RequestResult
Reponse to a login or similar request.
Note: this generic form is useful for parsing a result from A3, but you should never *return* a
RequestError
because then the status code won't be set correctly. Instead, throw a
GenericA3Error
or, even better, define and throw a custom error.
Eq RequestResult | |
Show RequestResult | |
Generic RequestResult | |
ToSample RequestResult | |
ToJSON RequestResult | |
FromJSON RequestResult | |
HasDocExtras (RestDocs Api) | |
type Rep RequestResult |
type ThentosApi = ("principals" :> ("users" :> (ReqBody `[JSON]` A3UserWithPass :> Post200 `[JSON]` TypedPathWithCacheControl))) :<|> (("activate_account" :> (ReqBody `[JSON]` ActivationRequest :> Post200 `[JSON]` RequestResult)) :<|> (("login_username" :> (ReqBody `[JSON]` LoginRequest :> Post200 `[JSON]` RequestResult)) :<|> (("login_email" :> (ReqBody `[JSON]` LoginRequest :> Post200 `[JSON]` RequestResult)) :<|> ("password_reset" :> (ReqBody `[JSON]` PasswordResetRequest :> Post200 `[JSON]` RequestResult)))))
Note: login_username and login_email have identical behavior. In
particular, it is not an error to send username and password to
/login_email
. This makes implementing all sides of the protocol
a lot easier without sacrificing security.
data TypedPath
Similar to A3Resource, but tailored for cases where path
and content_type
are present and
data
is absent (or irrelevant).
data TypedPathWithCacheControl
The A3 backend replies to POST request not just with a typed path, but also sends a listing of created/modified etc. resources along to allow the A3 frontend to update its cache.
TypedPathWithCacheControl | |
|
a3ProxyAdapter :: ProxyAdapter ThentosA3Error
A3-specific ProxyAdapter.
runBackend :: HttpConfig -> ActionState -> IO ()
serveApi :: Manager -> HttpConfig -> ActionState -> Application