Makes JWT generation possible in RPC endpoints

Fixes SET execution to execute in separate statements as Hasql uses
prepared statements we need to send 1 commend per statement.
This commit is contained in:
Diogo Biazus
2015-10-18 02:30:32 -04:00
parent aae55e0282
commit 241a38e958
4 changed files with 69 additions and 73 deletions
+3 -2
View File
@@ -35,7 +35,7 @@ runWithClaims :: forall s. AppConfig ->
(Request -> H.Tx P.Postgres s Response) ->
Request -> H.Tx P.Postgres s Response
runWithClaims conf app req = do
H.unitEx $ B.Stmt env V.empty True
mapM_ H.unitEx $ stmt <$> env
app req
where
hdrs = requestHeaders req
@@ -46,7 +46,8 @@ runWithClaims conf app req = do
case split (==' ') (cs auth) of
("Bearer" : jwt : _) -> fromMaybe [] (setJWTEnv jwtSecret jwt)
_ -> []
env = concat $ setRole anon : jwtEnv
env = setRole anon : jwtEnv
stmt = (flip $ flip B.Stmt V.empty) True
redirectInsecure :: Application -> Application
redirectInsecure app req respond = do