summaryrefslogtreecommitdiff
path: root/overlays/spm/lib/Spm
diff options
context:
space:
mode:
authorGregor Kleen <gkleen@yggdrasil.li>2022-06-07 21:38:00 +0200
committerGregor Kleen <gkleen@yggdrasil.li>2022-06-07 21:38:00 +0200
commit3bf77d7c3144b16d55f35998dddc0d67bb8c17b2 (patch)
tree805b343e50d733240b3dae8700d43060943b4dab /overlays/spm/lib/Spm
parentfc6cf6169868e60c189e4b243330c3717ff159f3 (diff)
downloadnixos-3bf77d7c3144b16d55f35998dddc0d67bb8c17b2.tar
nixos-3bf77d7c3144b16d55f35998dddc0d67bb8c17b2.tar.gz
nixos-3bf77d7c3144b16d55f35998dddc0d67bb8c17b2.tar.bz2
nixos-3bf77d7c3144b16d55f35998dddc0d67bb8c17b2.tar.xz
nixos-3bf77d7c3144b16d55f35998dddc0d67bb8c17b2.zip
...
Diffstat (limited to 'overlays/spm/lib/Spm')
-rw-r--r--overlays/spm/lib/Spm/Api.hs19
1 files changed, 17 insertions, 2 deletions
diff --git a/overlays/spm/lib/Spm/Api.hs b/overlays/spm/lib/Spm/Api.hs
index 14acfac4..c44a7951 100644
--- a/overlays/spm/lib/Spm/Api.hs
+++ b/overlays/spm/lib/Spm/Api.hs
@@ -2,7 +2,7 @@
2 2
3module Spm.Api 3module Spm.Api
4 ( SpmStyle(..), _SpmWords, _SpmConsonants 4 ( SpmStyle(..), _SpmWords, _SpmConsonants
5 , SpmMailbox 5 , SpmMailbox, SpmDomain
6 , SpmApi, spmApi 6 , SpmApi, spmApi
7 ) where 7 ) where
8 8
@@ -30,6 +30,8 @@ import Crypto.JWT.Instances ()
30import Data.UUID (UUID) 30import Data.UUID (UUID)
31import Data.UUID.Instances () 31import Data.UUID.Instances ()
32 32
33import qualified Data.Aeson as JSON
34
33-- import Data.Aeson (ToJSON, FromJSON) 35-- import Data.Aeson (ToJSON, FromJSON)
34 36
35 37
@@ -50,8 +52,20 @@ instance FromHttpApiData SpmStyle where
50 52
51newtype SpmMailbox = SpmMailbox { unSpmMailbox :: CI Text } 53newtype SpmMailbox = SpmMailbox { unSpmMailbox :: CI Text }
52 deriving stock (Eq, Ord, Read, Show, Generic, Typeable) 54 deriving stock (Eq, Ord, Read, Show, Generic, Typeable)
53 deriving newtype (MimeRender JSON, MimeRender PlainText) 55 deriving newtype (MimeRender PlainText)
54makeWrapped ''SpmMailbox 56makeWrapped ''SpmMailbox
57
58instance MimeRender JSON SpmMailbox where
59 mimeRender p mbox = mimeRender p $ JSON.object [ "mailbox" JSON..= unSpmMailbox mbox ]
60
61newtype SpmDomain = SpmDomain { unSpmDomain :: CI Text }
62 deriving stock (Eq, Ord, Read, Show, Generic, Typeable)
63 deriving newtype (MimeRender PlainText)
64makeWrapped ''SpmDomain
65
66instance MimeRender JSON SpmDomain where
67 mimeRender p dom = mimeRender p $ JSON.object [ "domain" JSON..= unSpmDomain dom ]
68
55-- newtype SpmLocal = SpmLocal 69-- newtype SpmLocal = SpmLocal
56-- { unSpmLocal :: CI Text 70-- { unSpmLocal :: CI Text
57-- } deriving stock (Eq, Ord, Read, Show, Generic, Typeable) 71-- } deriving stock (Eq, Ord, Read, Show, Generic, Typeable)
@@ -79,6 +93,7 @@ makeWrapped ''SpmMailbox
79-- ] 93-- ]
80 94
81type SpmApi = "whoami" :> Get '[PlainText, JSON] SpmMailbox 95type SpmApi = "whoami" :> Get '[PlainText, JSON] SpmMailbox
96 :<|> "domain" :> Get '[PlainText, JSON] SpmDomain
82 :<|> "jwks.json" :> Get '[JSON] JWKSet 97 :<|> "jwks.json" :> Get '[JSON] JWKSet
83 :<|> "instance-id" :> Get '[PlainText, JSON, OctetStream] UUID 98 :<|> "instance-id" :> Get '[PlainText, JSON, OctetStream] UUID
84 :<|> "spm" :> "generate" :> QueryParam "style" SpmStyle :> Get '[PlainText, JSON, OctetStream] SignedJWT 99 :<|> "spm" :> "generate" :> QueryParam "style" SpmStyle :> Get '[PlainText, JSON, OctetStream] SignedJWT