hoauth2 1.13.0 → 1.14.0
raw patch · 2 files changed
+12/−17 lines, 2 filesdep ~aesonPVP ok
version bump matches the API change (PVP)
Dependency ranges changed: aeson
API changes (from Hackage documentation)
Files
- example/App.hs +9/−14
- hoauth2.cabal +3/−3
example/App.hs view
@@ -8,7 +8,6 @@ module App (app, waiApp) where import Control.Monad-import Control.Monad.Error.Class import Control.Monad.IO.Class (MonadIO, liftIO) import Data.Bifunctor import Data.Maybe@@ -27,7 +26,6 @@ import Utils import Views import Web.Scotty-import Web.Scotty.Internal.Types ------------------------------ -- App@@ -64,9 +62,6 @@ redirectToHomeM :: ActionM () redirectToHomeM = redirect "/" -errorM :: Text -> ActionM ()-errorM = throwError . ActionError- globalErrorHandler :: Text -> ActionM () globalErrorHandler t = status status401 >> html t @@ -83,13 +78,13 @@ case eitherIdpApp of Right (IDPApp idp) -> do maybeIdpData <- lookIdp c idp- when (isNothing maybeIdpData) (errorM "refreshH: cannot find idp data from cache")+ when (isNothing maybeIdpData) (raise "refreshH: cannot find idp data from cache") let idpData = fromJust maybeIdpData re <- liftIO $ doRefreshToken idp idpData case re of Right newToken -> liftIO (print newToken) >> redirectToHomeM -- TODO: update access token in the store- Left e -> errorM (TL.pack e)- Left e -> errorM ("logout: unknown IDP " `TL.append` e)+ Left e -> raise (TL.pack e)+ Left e -> raise ("logout: unknown IDP " `TL.append` e) doRefreshToken :: HasTokenRefreshReq a => a -> IDPData -> IO (Either String OAuth2Token)@@ -110,7 +105,7 @@ -- let eitherIdpApp = parseIDP (head idpP) case eitherIdpApp of Right (IDPApp idp) -> liftIO (removeKey c (idpLabel idp)) >> redirectToHomeM- Left e -> errorM ("logout: unknown IDP " `TL.append` e)+ Left e -> raise ("logout: unknown IDP " `TL.append` e) indexH :: CacheStore -> ActionM () indexH c = liftIO (allValues c) >>= overviewTpl@@ -120,14 +115,14 @@ pas <- params let codeP = paramValue "code" pas let stateP = paramValue "state" pas- when (null codeP) (errorM "callbackH: no code from callback request")- when (null stateP) (errorM "callbackH: no state from callback request")+ when (null codeP) (raise "callbackH: no code from callback request")+ when (null stateP) (raise "callbackH: no state from callback request") let eitherIdpApp = parseIDP (TL.takeWhile (/= '.') (head stateP)) -- TODO: looks like `state` shall be passed when fetching access token -- turns out no IDP enforce this yet case eitherIdpApp of Right (IDPApp idp) -> fetchTokenAndUser c (head codeP) idp- Left e -> errorM ("callbackH: cannot find IDP name from text " `TL.append` e)+ Left e -> raise ("callbackH: cannot find IDP name from text " `TL.append` e) fetchTokenAndUser :: (HasTokenReq a, HasUserReq a, HasLabel a) => CacheStore@@ -136,13 +131,13 @@ -> ActionM () fetchTokenAndUser c code idp = do maybeIdpData <- lookIdp c idp- when (isNothing maybeIdpData) (errorM "fetchTokenAndUser: cannot find idp data from cache")+ when (isNothing maybeIdpData) (raise "fetchTokenAndUser: cannot find idp data from cache") let idpData = fromJust maybeIdpData result <- liftIO $ fetchTokenAndUser' c code idp idpData case result of Right _ -> redirectToHomeM- Left err -> errorM err+ Left err -> raise err fetchTokenAndUser' :: (HasTokenReq a, HasUserReq a) => CacheStore -> Text -> a -> IDPData -> IO (Either Text ())
hoauth2.cabal view
@@ -1,7 +1,7 @@ Cabal-version: 2.4 Name: hoauth2 -- http://wiki.haskell.org/Package_versioning_policy-Version: 1.13.0+Version: 1.14.0 Synopsis: Haskell OAuth2 authentication client @@ -80,7 +80,7 @@ bytestring >= 0.9 && < 0.11, http-conduit >= 2.1 && < 2.4, http-types >= 0.11 && < 0.13,- aeson >= 1.3.0.0 && < 1.5,+ aeson >= 1.3.0.0 && < 1.6, unordered-containers >= 0.2.5, uri-bytestring >= 0.2.3.1 && < 0.4, uri-bytestring-aeson >= 0.1 && < 0.2,@@ -127,7 +127,7 @@ wai >= 3.2 && < 3.3, warp >= 3.2 && < 3.4, containers >= 0.4 && < 0.7,- aeson >= 1.3.0.0 && < 1.5,+ aeson >= 1.3.0.0 && < 1.6, microlens >= 0.4.0 && < 0.5, unordered-containers >= 0.2.5, wai-extra >= 3.0.21.0 && < 3.1,