Use sql to generate jwt, rather than custom haskell

This commit is contained in:
Joe Nelson
2016-09-24 21:32:47 -07:00
parent 62ed9e2c4d
commit 12a8c682bd
7 changed files with 43 additions and 48 deletions
+5
View File
@@ -19,6 +19,7 @@ import PostgREST.ApiRequest (ApiRequest(..), ContentType(..),
import PostgREST.Auth (claimsToSQL, JWTAttempt(..))
import PostgREST.Config (AppConfig (..), corsPolicy)
import PostgREST.Error (errResponse)
import PostgREST.QueryBuilder (pgFmtLit)
import Protolude hiding (concat, null)
@@ -45,6 +46,10 @@ runWithClaims conf eClaims app req =
]
(toS $ "{\"message\":\""<>message<>"\"}")
exposeSecretToSQL :: Maybe Text -> H.Transaction ()
exposeSecretToSQL mS = do
for_ mS $ \s ->
H.sql $ "set local postgrest.jwt_secret = " <> toS (pgFmtLit s) <> ";"
defaultMiddle :: Application -> Application
defaultMiddle =