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