Delayed handler for Lax authentication
This commit is contained in:
parent
1aca415ec7
commit
ee1e0fe355
1 changed files with 11 additions and 1 deletions
|
@ -183,7 +183,6 @@ addMethodCheck (Delayed captures method auth body server) new =
|
||||||
addAuthStrictCheck :: Delayed (AuthProtected auth usr (usr -> a) 'Strict)
|
addAuthStrictCheck :: Delayed (AuthProtected auth usr (usr -> a) 'Strict)
|
||||||
-> IO (RouteResult (Maybe auth))
|
-> IO (RouteResult (Maybe auth))
|
||||||
-> Delayed a
|
-> Delayed a
|
||||||
-- -> Delayed a
|
|
||||||
addAuthStrictCheck delayed@(Delayed captures method _ body _) new =
|
addAuthStrictCheck delayed@(Delayed captures method _ body _) new =
|
||||||
let newAuth = runDelayed delayed `bindRouteResults` \authProtectionStrict -> new `bindRouteResults` \mAuthData -> case mAuthData of
|
let newAuth = runDelayed delayed `bindRouteResults` \authProtectionStrict -> new `bindRouteResults` \mAuthData -> case mAuthData of
|
||||||
|
|
||||||
|
@ -207,6 +206,17 @@ addAuthStrictCheck delayed@(Delayed captures method _ body _) new =
|
||||||
(return . Route . subServerStrict authProtectionStrict) usr
|
(return . Route . subServerStrict authProtectionStrict) usr
|
||||||
in Delayed captures method newAuth body (\_ y _ -> Route y)
|
in Delayed captures method newAuth body (\_ y _ -> Route y)
|
||||||
|
|
||||||
|
-- | Add a method to perform authorization in strict mode.
|
||||||
|
addAuthLaxCheck :: Delayed (AuthProtected auth usr (Maybe usr -> a) 'Lax)
|
||||||
|
-> IO (RouteResult (Maybe auth))
|
||||||
|
-> Delayed a
|
||||||
|
addAuthLaxCheck delayed@(Delayed captures method _ body _) new =
|
||||||
|
let newAuth = runDelayed delayed `bindRouteResults` \authProtectionLax -> new `bindRouteResults` \mAuthData ->
|
||||||
|
fmap (Route . subServerLax authProtectionLax)
|
||||||
|
(maybe (pure Nothing) (checkAuthLax authProtectionLax) mAuthData)
|
||||||
|
|
||||||
|
in Delayed captures method newAuth body (\_ y _ -> Route y)
|
||||||
|
|
||||||
-- | Add a body check to the end of the body block.
|
-- | Add a body check to the end of the body block.
|
||||||
addBodyCheck :: Delayed (a -> b)
|
addBodyCheck :: Delayed (a -> b)
|
||||||
-> IO (RouteResult a)
|
-> IO (RouteResult a)
|
||||||
|
|
Loading…
Reference in a new issue