mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-09 11:23:54 +02:00
Implement review feedback
This commit is contained in:
parent
be02edc2e8
commit
1d6701762c
@ -2,9 +2,8 @@
|
|||||||
|
|
||||||
## [v0.7.0.3](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.7.0.2...v0.7.0.3)
|
## [v0.7.0.3](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.7.0.2...v0.7.0.3)
|
||||||
|
|
||||||
- Support `hoauth-2.7`, this change is breaking if something other than
|
- Support `hoauth-2.7`. This change is only breaking in the unlikely case of users
|
||||||
than `fetchAccessToken` or `fetchAccessToken2` is used build the plugin (which
|
using something other than `fetchAccessToken` or `fetchAccessToken2`
|
||||||
we don't believe to be the case)
|
|
||||||
|
|
||||||
## [v0.7.0.2](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.7.0.1...v0.7.0.2)
|
## [v0.7.0.2](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.7.0.1...v0.7.0.2)
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@
|
|||||||
module Network.OAuth.OAuth2.Compat
|
module Network.OAuth.OAuth2.Compat
|
||||||
( OAuth2(..)
|
( OAuth2(..)
|
||||||
, OAuth2Result
|
, OAuth2Result
|
||||||
, Error
|
, Errors
|
||||||
, authorizationUrl
|
, authorizationUrl
|
||||||
, fetchAccessToken
|
, fetchAccessToken
|
||||||
, fetchAccessToken2
|
, fetchAccessToken2
|
||||||
@ -16,6 +16,7 @@ module Network.OAuth.OAuth2.Compat
|
|||||||
import Data.ByteString.Lazy (ByteString)
|
import Data.ByteString.Lazy (ByteString)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
import Network.HTTP.Conduit (Manager)
|
import Network.HTTP.Conduit (Manager)
|
||||||
|
import qualified Network.OAuth.OAuth2 as OAuth2
|
||||||
#if MIN_VERSION_hoauth2(2,7,0)
|
#if MIN_VERSION_hoauth2(2,7,0)
|
||||||
import Network.OAuth.OAuth2
|
import Network.OAuth.OAuth2
|
||||||
( AccessToken(..)
|
( AccessToken(..)
|
||||||
@ -23,6 +24,7 @@ import Network.OAuth.OAuth2
|
|||||||
, OAuth2Token(..)
|
, OAuth2Token(..)
|
||||||
, RefreshToken(..)
|
, RefreshToken(..)
|
||||||
)
|
)
|
||||||
|
import Network.OAuth.OAuth2.TokenRequest (TokenRequestError)
|
||||||
#else
|
#else
|
||||||
import Network.OAuth.OAuth2
|
import Network.OAuth.OAuth2
|
||||||
( AccessToken(..)
|
( AccessToken(..)
|
||||||
@ -31,12 +33,7 @@ import Network.OAuth.OAuth2
|
|||||||
, OAuth2Token(..)
|
, OAuth2Token(..)
|
||||||
, RefreshToken(..)
|
, RefreshToken(..)
|
||||||
)
|
)
|
||||||
#endif
|
import qualified Network.OAuth.OAuth2.TokenRequest as LegacyTokenRequest
|
||||||
import qualified Network.OAuth.OAuth2 as OAuth2
|
|
||||||
#if MIN_VERSION_hoauth2(2,7,0)
|
|
||||||
import Network.OAuth.OAuth2.TokenRequest (TokenRequestError)
|
|
||||||
#else
|
|
||||||
import Network.OAuth.OAuth2.TokenRequest (Errors)
|
|
||||||
#endif
|
#endif
|
||||||
import URI.ByteString
|
import URI.ByteString
|
||||||
|
|
||||||
@ -54,9 +51,9 @@ data OAuth2 = OAuth2
|
|||||||
}
|
}
|
||||||
|
|
||||||
#if MIN_VERSION_hoauth2(2,7,0)
|
#if MIN_VERSION_hoauth2(2,7,0)
|
||||||
type Error = TokenRequestError
|
type Errors = TokenRequestError
|
||||||
#else
|
#else
|
||||||
type Error = OAuth2Error Errors
|
type Errors = OAuth2Error LegacyTokenRequest.Errors
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
type OAuth2Result err a = Either err a
|
type OAuth2Result err a = Either err a
|
||||||
@ -68,14 +65,14 @@ fetchAccessToken
|
|||||||
:: Manager
|
:: Manager
|
||||||
-> OAuth2
|
-> OAuth2
|
||||||
-> ExchangeToken
|
-> ExchangeToken
|
||||||
-> IO (OAuth2Result Error OAuth2Token)
|
-> IO (OAuth2Result Errors OAuth2Token)
|
||||||
fetchAccessToken = fetchAccessTokenBasic
|
fetchAccessToken = fetchAccessTokenBasic
|
||||||
|
|
||||||
fetchAccessToken2
|
fetchAccessToken2
|
||||||
:: Manager
|
:: Manager
|
||||||
-> OAuth2
|
-> OAuth2
|
||||||
-> ExchangeToken
|
-> ExchangeToken
|
||||||
-> IO (OAuth2Result Error OAuth2Token)
|
-> IO (OAuth2Result Errors OAuth2Token)
|
||||||
fetchAccessToken2 = fetchAccessTokenPost
|
fetchAccessToken2 = fetchAccessTokenPost
|
||||||
|
|
||||||
authGetBS :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
|
authGetBS :: Manager -> AccessToken -> URI -> IO (Either ByteString ByteString)
|
||||||
@ -151,7 +148,7 @@ fetchAccessTokenBasic
|
|||||||
:: Manager
|
:: Manager
|
||||||
-> OAuth2
|
-> OAuth2
|
||||||
-> ExchangeToken
|
-> ExchangeToken
|
||||||
-> IO (OAuth2Result Error OAuth2Token)
|
-> IO (OAuth2Result Errors OAuth2Token)
|
||||||
fetchAccessTokenBasic m o e = runOAuth2 $ f m (getOAuth2 o) e
|
fetchAccessTokenBasic m o e = runOAuth2 $ f m (getOAuth2 o) e
|
||||||
where
|
where
|
||||||
#if MIN_VERSION_hoauth2(2,6,0)
|
#if MIN_VERSION_hoauth2(2,6,0)
|
||||||
@ -166,7 +163,7 @@ fetchAccessTokenPost
|
|||||||
:: Manager
|
:: Manager
|
||||||
-> OAuth2
|
-> OAuth2
|
||||||
-> ExchangeToken
|
-> ExchangeToken
|
||||||
-> IO (OAuth2Result Error OAuth2Token)
|
-> IO (OAuth2Result Errors OAuth2Token)
|
||||||
fetchAccessTokenPost m o e = runOAuth2 $ f m (getOAuth2 o) e
|
fetchAccessTokenPost m o e = runOAuth2 $ f m (getOAuth2 o) e
|
||||||
where
|
where
|
||||||
#if MIN_VERSION_hoauth2(2, 6, 0)
|
#if MIN_VERSION_hoauth2(2, 6, 0)
|
||||||
|
|||||||
@ -18,8 +18,8 @@ import qualified Data.Text as T
|
|||||||
import Data.Text.Encoding (encodeUtf8)
|
import Data.Text.Encoding (encodeUtf8)
|
||||||
import Network.HTTP.Conduit (Manager)
|
import Network.HTTP.Conduit (Manager)
|
||||||
import Network.OAuth.OAuth2.Compat
|
import Network.OAuth.OAuth2.Compat
|
||||||
import UnliftIO.Exception
|
|
||||||
import URI.ByteString.Extension
|
import URI.ByteString.Extension
|
||||||
|
import UnliftIO.Exception
|
||||||
import Yesod.Auth hiding (ServerError)
|
import Yesod.Auth hiding (ServerError)
|
||||||
import Yesod.Auth.OAuth2.DispatchError
|
import Yesod.Auth.OAuth2.DispatchError
|
||||||
import Yesod.Auth.OAuth2.ErrorResponse
|
import Yesod.Auth.OAuth2.ErrorResponse
|
||||||
@ -31,7 +31,7 @@ import Yesod.Core hiding (ErrorResponse)
|
|||||||
-- This will be 'fetchAccessToken' or 'fetchAccessToken2'
|
-- This will be 'fetchAccessToken' or 'fetchAccessToken2'
|
||||||
--
|
--
|
||||||
type FetchToken
|
type FetchToken
|
||||||
= Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Error OAuth2Token)
|
= Manager -> OAuth2 -> ExchangeToken -> IO (OAuth2Result Errors OAuth2Token)
|
||||||
|
|
||||||
-- | How to take an @'OAuth2Token'@ and retrieve user credentials
|
-- | How to take an @'OAuth2Token'@ and retrieve user credentials
|
||||||
type FetchCreds m = Manager -> OAuth2Token -> IO (Creds m)
|
type FetchCreds m = Manager -> OAuth2Token -> IO (Creds m)
|
||||||
|
|||||||
@ -16,7 +16,7 @@ module Yesod.Auth.OAuth2.DispatchError
|
|||||||
|
|
||||||
import Control.Monad.Except
|
import Control.Monad.Except
|
||||||
import Data.Text (Text, pack)
|
import Data.Text (Text, pack)
|
||||||
import Network.OAuth.OAuth2.Compat (Error)
|
import Network.OAuth.OAuth2.Compat (Errors)
|
||||||
import UnliftIO.Except ()
|
import UnliftIO.Except ()
|
||||||
import UnliftIO.Exception
|
import UnliftIO.Exception
|
||||||
import Yesod.Auth hiding (ServerError)
|
import Yesod.Auth hiding (ServerError)
|
||||||
@ -30,7 +30,7 @@ data DispatchError
|
|||||||
| InvalidStateToken (Maybe Text) Text
|
| InvalidStateToken (Maybe Text) Text
|
||||||
| InvalidCallbackUri Text
|
| InvalidCallbackUri Text
|
||||||
| OAuth2HandshakeError ErrorResponse
|
| OAuth2HandshakeError ErrorResponse
|
||||||
| OAuth2ResultError Error
|
| OAuth2ResultError Errors
|
||||||
| FetchCredsIOException IOException
|
| FetchCredsIOException IOException
|
||||||
| FetchCredsYesodOAuth2Exception YesodOAuth2Exception
|
| FetchCredsYesodOAuth2Exception YesodOAuth2Exception
|
||||||
| OtherDispatchError Text
|
| OtherDispatchError Text
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user