Authd: authentication by token (useful on page reload).

beta
Philippe Pittoli 2024-02-17 18:47:55 +01:00
parent b6655a0ee0
commit 98a30b6c1d
1 changed files with 7 additions and 0 deletions

View File

@ -164,6 +164,11 @@ codecSearchUser
{ regex: CAR.optional CA.string
, offset: CAR.optional CA.int })
{- 13 and 14: these messages are not designed for clients. -}
{- 15 -}
type AuthByToken = { token :: String }
codecAuthByToken ∷ CA.JsonCodec AuthByToken
codecAuthByToken = CA.object "AuthByToken" (CAR.record { token: CA.string })
{-
RESPONSES
@ -345,6 +350,7 @@ data RequestMessage
| MkCheckPermission CheckPermission -- 10
| MkSetPermission SetPermission -- 11
| MkSearchUser SearchUser -- 12
| MkAuthByToken AuthByToken -- 15
-- All possible answers from the authentication daemon (authd).
data AnswerMessage
@ -395,6 +401,7 @@ encode m = case m of
(MkCheckPermission request) -> get_tuple 10 codecCheckPermission request
(MkSetPermission request) -> get_tuple 11 codecSetPermission request
(MkSearchUser request) -> get_tuple 12 codecSearchUser request
(MkAuthByToken request) -> get_tuple 15 codecAuthByToken request
where
get_tuple :: forall a. Int -> CA.JsonCodec a -> a -> Tuple UInt String
get_tuple num codec request = Tuple (fromInt num) (J.stringify $ CA.encode codec request)