apiary-authenticate 1.2.1 → 1.3.0
raw patch · 3 files changed
+20/−16 lines, 3 filesdep +web-routingdep ~apiarydep ~apiary-sessiondep ~blaze-builderPVP ok
version bump matches the API change (PVP)
Dependencies added: web-routing
Dependency ranges changed: apiary, apiary-session, blaze-builder
API changes (from Hackage documentation)
- Web.Apiary.Authenticate: authorized :: (Has (Session OpenId actM) exts, Monad actM, NotMember "auth" kvs) => ApiaryT exts (("auth" := OpenId) : kvs) actM m () -> ApiaryT exts kvs actM m ()
+ Web.Apiary.Authenticate: authorized :: (Has (Session OpenId actM) exts, Monad actM, "auth" </ kvs) => Filter exts actM m kvs (("auth" := OpenId) : kvs)
- Web.Apiary.Authenticate: authorized' :: (Has (Session OpenId actM) exts, KnownSymbol key, Monad actM, NotMember key kvs) => proxy key -> ApiaryT exts ((key := OpenId) : kvs) actM m () -> ApiaryT exts kvs actM m ()
+ Web.Apiary.Authenticate: authorized' :: (Has (Session OpenId actM) exts, KnownSymbol key, Monad actM, key </ kvs) => proxy key -> Filter exts actM m kvs ((key := OpenId) : kvs)
Files
- apiary-authenticate.cabal +5/−4
- src/Web/Apiary/Authenticate.hs +6/−7
- src/Web/Apiary/Authenticate/Internal.hs +9/−5
apiary-authenticate.cabal view
@@ -1,5 +1,5 @@ name: apiary-authenticate-version: 1.2.1+version: 1.3.0 synopsis: authenticate support for apiary web framework. description: example: <https://github.com/philopon/apiary/blob/master/examples/auth.hs>@@ -9,7 +9,7 @@ maintainer: HirotomoMoriwaki<philopon.dependence@gmail.com> Homepage: https://github.com/philopon/apiary Bug-reports: https://github.com/philopon/apiary/issues-copyright: (c) 2014 Hirotomo Moriwaki+copyright: (c) 2014-2015 Hirotomo Moriwaki category: Web build-type: Simple stability: stable@@ -20,8 +20,8 @@ exposed-modules: Web.Apiary.Authenticate other-modules: Web.Apiary.Authenticate.Internal build-depends: base >=4.6 && <4.8- , apiary >=1.2 && <1.3- , apiary-session >=1.2 && <1.3+ , apiary >=1.3 && <1.4+ , apiary-session >=1.3 && <1.4 , authenticate >=1.3.2.10 && <1.4 , wai >=3.0 && <3.1 @@ -38,6 +38,7 @@ , resourcet >=1.1 && <1.2 , blaze-builder >=0.3 && <0.4+ , web-routing hs-source-dirs: src ghc-options: -O2 -Wall
src/Web/Apiary/Authenticate.hs view
@@ -23,18 +23,19 @@ import Web.Apiary import qualified Web.Apiary.Authenticate.Internal as I+import qualified Network.Routing.Dict as Dict import qualified Network.HTTP.Client as Client import Network.HTTP.Client.TLS(tlsManagerSettings) import Web.Apiary.Session import Control.Monad import Control.Monad.Trans.Control+import Control.Monad.Apiary.Filter(Filter) import qualified Data.Text as T import qualified Data.ByteString as S import Data.Apiary.Compat import Data.Apiary.Extension-import qualified Data.Apiary.Dict as Dict pOpenId :: Proxy I.OpenId pOpenId = Proxy@@ -59,16 +60,14 @@ => ApiaryT exts prms actM m () authHandler = getExt (Proxy :: Proxy I.Auth) >>= I.authHandler -authorized' :: (Has (Session I.OpenId actM) exts, KnownSymbol key, Monad actM, Dict.NotMember key kvs)+authorized' :: (Has (Session I.OpenId actM) exts, KnownSymbol key, Monad actM, key Dict.</ kvs) => proxy key- -> ApiaryT exts (key := I.OpenId ': kvs) actM m ()- -> ApiaryT exts kvs actM m ()+ -> Filter exts actM m kvs (key := I.OpenId ': kvs) authorized' ky = session' ky (Proxy :: Proxy I.OpenId) -- | filter which check whether logged in or not, and get id. since 0.7.0.0.-authorized :: (Has (Session I.OpenId actM) exts, Monad actM, Dict.NotMember "auth" kvs)- => ApiaryT exts ("auth" := I.OpenId ': kvs) actM m ()- -> ApiaryT exts kvs actM m ()+authorized :: (Has (Session I.OpenId actM) exts, Monad actM, "auth" Dict.</ kvs)+ => Filter exts actM m kvs ("auth" := I.OpenId ': kvs) authorized = authorized' (Proxy :: Proxy "auth") authConfig :: (Has I.Auth exts, Monad m) => ActionT exts prms m I.AuthConfig
src/Web/Apiary/Authenticate/Internal.hs view
@@ -12,9 +12,10 @@ module Web.Apiary.Authenticate.Internal where import Control.Applicative((<$>), (<*>))+import Control.Monad(mzero) import Control.Monad.Trans.Resource(runResourceT) import Control.Monad.Apiary(ApiaryT, action)-import Control.Monad.Apiary.Filter(function, method)+import Control.Monad.Apiary.Filter(focus) import Control.Monad.Apiary.Action(ActionT, getRequest, redirect) import qualified Network.Wai as Wai@@ -28,11 +29,11 @@ import Data.Apiary.Extension(Has, Extension) import Data.Apiary.Compat(Proxy(Proxy), Typeable) import Data.Apiary.Method(Method(GET))+import qualified Network.Routing as R import qualified Data.Serialize as Serialize import Data.Data (Data) import Data.Maybe(mapMaybe)-import Data.List(isPrefixOf) import Data.Default.Class(Default(..)) import Blaze.ByteString.Builder(toByteString)@@ -74,12 +75,15 @@ => Auth -> ApiaryT exts prms actM m () authHandler Auth{..} = retH >> mapM_ (uncurry go) (providers config) where- pfxPath p = function id (\d r -> if p `isPrefixOf` Wai.pathInfo r then Just d else Nothing)+ pfxPath p = focus id (Just GET) $ R.raw "" $ \d t -> do+ if t == p+ then return (d, [])+ else mzero - retH = pfxPath (authPrefix config ++ authReturnToPath config) . method GET . action $+ retH = pfxPath (authPrefix config ++ authReturnToPath config) . action $ returnAction manager (authSuccessPage config) - go name Provider{..} = pfxPath (authPrefix config ++ [name]) . method GET . action $+ go name Provider{..} = pfxPath (authPrefix config ++ [name]) . action $ authAction manager providerUrl returnTo realm parameters returnTo = T.decodeUtf8 $ T.encodeUtf8 (authUrl config) `S.append`