module Cachix.Types.Session
( Session (..),
)
where
import qualified Crypto.JWT as JWT
import Protolude
import Servant.Auth.JWT (FromJWT (..), ToJWT (..))
data Session
= JWTSession JWT.ClaimsSet
deriving (Session -> Session -> Bool
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: Session -> Session -> Bool
$c/= :: Session -> Session -> Bool
== :: Session -> Session -> Bool
$c== :: Session -> Session -> Bool
Eq)
instance ToJWT Session where
encodeJWT :: Session -> ClaimsSet
encodeJWT (JWTSession ClaimsSet
s) = ClaimsSet
s
instance FromJWT Session where
decodeJWT :: ClaimsSet -> Either Text Session
decodeJWT ClaimsSet
cs = forall (f :: * -> *) a. Applicative f => a -> f a
pure forall a b. (a -> b) -> a -> b
$ ClaimsSet -> Session
JWTSession ClaimsSet
cs