Fix custom pre-request handler

Uses Ruslan's technique
This commit is contained in:
Joe Nelson
2016-09-27 23:17:08 -07:00
parent 06363ccc77
commit 5a166e8e80
7 changed files with 63 additions and 17 deletions
+3 -3
View File
@@ -33,12 +33,12 @@ runWithClaims conf eClaims app req =
JWTClaims claims -> do
-- role claim defaults to anon if not specified in jwt
let setClaims = claimsToSQL (M.union claims (M.singleton "role" anon))
H.sql (mconcat $ setClaims ++ customReqCheck)
H.sql $ mconcat setClaims
mapM_ H.sql customReqCheck
app req
where
anon = String . toS $ configAnonRole conf
customReqCheck = maybeToList $ (\f -> "select " <> toS f <> "();")
<$> configReqCheck conf
customReqCheck = (\f -> "select " <> toS f <> "();") <$> configReqCheck conf
unauthed message = responseLBS unauthorized401
[ ctToHeader CTApplicationJSON
, ( "WWW-Authenticate"