mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-04 08:53:49 +02:00
Reformat everything with Brittany
This commit is contained in:
parent
e3730ab99c
commit
d34efc18ca
@ -19,24 +19,20 @@ instance IsString Host where
|
|||||||
fromString = Host . fromString
|
fromString = Host . fromString
|
||||||
|
|
||||||
instance IsString (URIRef Absolute) where
|
instance IsString (URIRef Absolute) where
|
||||||
fromString = either (error . show) id
|
fromString =
|
||||||
. parseURI strictURIParserOptions
|
either (error . show) id . parseURI strictURIParserOptions . C8.pack
|
||||||
. C8.pack
|
|
||||||
|
|
||||||
instance IsString (URIRef Relative) where
|
instance IsString (URIRef Relative) where
|
||||||
fromString = either (error . show) id
|
fromString =
|
||||||
. parseRelativeRef strictURIParserOptions
|
either (error . show) id . parseRelativeRef strictURIParserOptions . C8.pack
|
||||||
. C8.pack
|
|
||||||
|
|
||||||
fromText :: Text -> Maybe URI
|
fromText :: Text -> Maybe URI
|
||||||
fromText = either (const Nothing) Just
|
fromText =
|
||||||
. parseURI strictURIParserOptions
|
either (const Nothing) Just . parseURI strictURIParserOptions . encodeUtf8
|
||||||
. encodeUtf8
|
|
||||||
|
|
||||||
unsafeFromText :: Text -> URI
|
unsafeFromText :: Text -> URI
|
||||||
unsafeFromText = either (error . show) id
|
unsafeFromText =
|
||||||
. parseURI strictURIParserOptions
|
either (error . show) id . parseURI strictURIParserOptions . encodeUtf8
|
||||||
. encodeUtf8
|
|
||||||
|
|
||||||
toText :: URI -> Text
|
toText :: URI -> Text
|
||||||
toText = decodeUtf8 . serializeURIRef'
|
toText = decodeUtf8 . serializeURIRef'
|
||||||
|
|||||||
@ -36,11 +36,13 @@ oauth2Auth0HostScopes
|
|||||||
:: YesodAuth m => URI -> [Text] -> Text -> Text -> AuthPlugin m
|
:: YesodAuth m => URI -> [Text] -> Text -> Text -> AuthPlugin m
|
||||||
oauth2Auth0HostScopes host scopes clientId clientSecret =
|
oauth2Auth0HostScopes host scopes clientId clientSecret =
|
||||||
authOAuth2 pluginName oauth2 $ \manager token -> do
|
authOAuth2 pluginName oauth2 $ \manager token -> do
|
||||||
(User uid, userResponse) <- authGetProfile pluginName
|
(User uid, userResponse) <- authGetProfile
|
||||||
|
pluginName
|
||||||
manager
|
manager
|
||||||
token
|
token
|
||||||
(host `withPath` "/userinfo")
|
(host `withPath` "/userinfo")
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = uid
|
, credsIdent = uid
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -48,9 +50,8 @@ oauth2Auth0HostScopes host scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = host
|
, oauth2AuthorizeEndpoint =
|
||||||
`withPath` "/authorize"
|
host `withPath` "/authorize" `withQuery` [scopeParam " " scopes]
|
||||||
`withQuery` [scopeParam " " scopes]
|
|
||||||
, oauth2TokenEndpoint = host `withPath` "/oauth/token"
|
, oauth2TokenEndpoint = host `withPath` "/oauth/token"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@ -37,7 +37,8 @@ oauth2AzureADScoped scopes clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://graph.microsoft.com/v1.0/me"
|
"https://graph.microsoft.com/v1.0/me"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = userId
|
, credsIdent = userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
|
|||||||
@ -39,7 +39,8 @@ oauth2BattleNet widget region clientId clientSecret =
|
|||||||
authGetProfile pluginName manager token
|
authGetProfile pluginName manager token
|
||||||
$ fromRelative "https" (apiHost $ T.toLower region) "/account/user"
|
$ fromRelative "https" (apiHost $ T.toLower region) "/account/user"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = T.pack $ show userId
|
, credsIdent = T.pack $ show userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,8 @@ oauth2BitbucketScoped scopes clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://api.bitbucket.com/2.0/user"
|
"https://api.bitbucket.com/2.0/user"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
-- FIXME: Preserved bug. This should just be userId (it's already
|
-- FIXME: Preserved bug. This should just be userId (it's already
|
||||||
-- a Text), but because this code was shipped, folks likely have
|
-- a Text), but because this code was shipped, folks likely have
|
||||||
-- Idents in their database like @"\"...\""@, and if we fixed this
|
-- Idents in their database like @"\"...\""@, and if we fixed this
|
||||||
@ -52,7 +53,8 @@ oauth2BitbucketScoped scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://bitbucket.com/site/oauth2/authorize"
|
, oauth2AuthorizeEndpoint =
|
||||||
|
"https://bitbucket.com/site/oauth2/authorize"
|
||||||
`withQuery` [scopeParam "," scopes]
|
`withQuery` [scopeParam "," scopes]
|
||||||
, oauth2TokenEndpoint = "https://bitbucket.com/site/oauth2/access_token"
|
, oauth2TokenEndpoint = "https://bitbucket.com/site/oauth2/access_token"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
|
|||||||
@ -32,7 +32,8 @@ oauth2ClassLinkScoped scopes clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://nodeapi.classlink.com/v2/my/info"
|
"https://nodeapi.classlink.com/v2/my/info"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = T.pack $ show userId
|
, credsIdent = T.pack $ show userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -40,7 +41,8 @@ oauth2ClassLinkScoped scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://launchpad.classlink.com/oauth2/v2/auth"
|
, oauth2AuthorizeEndpoint =
|
||||||
|
"https://launchpad.classlink.com/oauth2/v2/auth"
|
||||||
`withQuery` [scopeParam "," scopes]
|
`withQuery` [scopeParam "," scopes]
|
||||||
, oauth2TokenEndpoint = "https://launchpad.classlink.com/oauth2/v2/token"
|
, oauth2TokenEndpoint = "https://launchpad.classlink.com/oauth2/v2/token"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
|
|||||||
@ -104,8 +104,8 @@ withCallbackAndState name oauth2 csrf = do
|
|||||||
callback <- maybe (throwError $ InvalidCallbackUri uri) pure $ fromText uri
|
callback <- maybe (throwError $ InvalidCallbackUri uri) pure $ fromText uri
|
||||||
pure oauth2
|
pure oauth2
|
||||||
{ oauth2RedirectUri = Just callback
|
{ oauth2RedirectUri = Just callback
|
||||||
, oauth2AuthorizeEndpoint = oauth2AuthorizeEndpoint oauth2
|
, oauth2AuthorizeEndpoint =
|
||||||
`withQuery` [("state", encodeUtf8 csrf)]
|
oauth2AuthorizeEndpoint oauth2 `withQuery` [("state", encodeUtf8 csrf)]
|
||||||
}
|
}
|
||||||
|
|
||||||
getParentUrlRender :: MonadHandler m => m (Route (SubHandlerSite m) -> Text)
|
getParentUrlRender :: MonadHandler m => m (Route (SubHandlerSite m) -> Text)
|
||||||
@ -133,7 +133,8 @@ verifySessionCSRF sessionKey = do
|
|||||||
token <- requireGetParam "state"
|
token <- requireGetParam "state"
|
||||||
sessionToken <- lookupSession sessionKey
|
sessionToken <- lookupSession sessionKey
|
||||||
deleteSession sessionKey
|
deleteSession sessionKey
|
||||||
token <$ unless (sessionToken == Just token)
|
token <$ unless
|
||||||
|
(sessionToken == Just token)
|
||||||
(throwError $ InvalidStateToken sessionToken token)
|
(throwError $ InvalidStateToken sessionToken token)
|
||||||
|
|
||||||
requireGetParam
|
requireGetParam
|
||||||
|
|||||||
@ -69,7 +69,8 @@ onDispatchError err = do
|
|||||||
let suffix = " [errorId=" <> errorId <> "]"
|
let suffix = " [errorId=" <> errorId <> "]"
|
||||||
$(logError) $ pack (displayException err) <> suffix
|
$(logError) $ pack (displayException err) <> suffix
|
||||||
|
|
||||||
let message = dispatchErrorMessage err <> suffix
|
let
|
||||||
|
message = dispatchErrorMessage err <> suffix
|
||||||
messageValue =
|
messageValue =
|
||||||
object ["error" .= object ["id" .= errorId, "message" .= message]]
|
object ["error" .= object ["id" .= errorId, "message" .= message]]
|
||||||
|
|
||||||
|
|||||||
@ -9,8 +9,7 @@ module Yesod.Auth.OAuth2.ErrorResponse
|
|||||||
, ErrorName(..)
|
, ErrorName(..)
|
||||||
, onErrorResponse
|
, onErrorResponse
|
||||||
, unknownError
|
, unknownError
|
||||||
)
|
) where
|
||||||
where
|
|
||||||
|
|
||||||
import Data.Foldable (traverse_)
|
import Data.Foldable (traverse_)
|
||||||
import Data.Text (Text)
|
import Data.Text (Text)
|
||||||
@ -48,11 +47,8 @@ erUserMessage err = case erName err of
|
|||||||
Unknown _ -> "Unknown error"
|
Unknown _ -> "Unknown error"
|
||||||
|
|
||||||
unknownError :: Text -> ErrorResponse
|
unknownError :: Text -> ErrorResponse
|
||||||
unknownError x = ErrorResponse
|
unknownError x =
|
||||||
{ erName = Unknown x
|
ErrorResponse { erName = Unknown x, erDescription = Nothing, erURI = Nothing }
|
||||||
, erDescription = Nothing
|
|
||||||
, erURI = Nothing
|
|
||||||
}
|
|
||||||
|
|
||||||
-- | Check query parameters for an error, if found run the given action
|
-- | Check query parameters for an error, if found run the given action
|
||||||
--
|
--
|
||||||
|
|||||||
@ -63,7 +63,8 @@ oauth2EveScoped scopes widgetType clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://login.eveonline.com/oauth/verify"
|
"https://login.eveonline.com/oauth/verify"
|
||||||
|
|
||||||
pure Creds { credsPlugin = "eveonline"
|
pure Creds
|
||||||
|
{ credsPlugin = "eveonline"
|
||||||
-- FIXME: Preserved bug. See similar comment in Bitbucket provider.
|
-- FIXME: Preserved bug. See similar comment in Bitbucket provider.
|
||||||
, credsIdent = T.pack $ show userId
|
, credsIdent = T.pack $ show userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
@ -72,10 +73,9 @@ oauth2EveScoped scopes widgetType clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://login.eveonline.com/oauth/authorize"
|
, oauth2AuthorizeEndpoint =
|
||||||
`withQuery` [ ("response_type", "code")
|
"https://login.eveonline.com/oauth/authorize"
|
||||||
, scopeParam " " scopes
|
`withQuery` [("response_type", "code"), scopeParam " " scopes]
|
||||||
]
|
|
||||||
, oauth2TokenEndpoint = "https://login.eveonline.com/oauth/token"
|
, oauth2TokenEndpoint = "https://login.eveonline.com/oauth/token"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@ -38,7 +38,8 @@ oauth2GitHubScoped scopes clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://api.github.com/user"
|
"https://api.github.com/user"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = T.pack $ show userId
|
, credsIdent = T.pack $ show userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -46,7 +47,8 @@ oauth2GitHubScoped scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://github.com/login/oauth/authorize"
|
, oauth2AuthorizeEndpoint =
|
||||||
|
"https://github.com/login/oauth/authorize"
|
||||||
`withQuery` [scopeParam "," scopes]
|
`withQuery` [scopeParam "," scopes]
|
||||||
, oauth2TokenEndpoint = "https://github.com/login/oauth/access_token"
|
, oauth2TokenEndpoint = "https://github.com/login/oauth/access_token"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
|
|||||||
@ -43,7 +43,8 @@ oauth2GitLabHostScopes host scopes clientId clientSecret =
|
|||||||
(User userId, userResponse) <-
|
(User userId, userResponse) <-
|
||||||
authGetProfile pluginName manager token $ host `withPath` "/api/v4/user"
|
authGetProfile pluginName manager token $ host `withPath` "/api/v4/user"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = T.pack $ show userId
|
, credsIdent = T.pack $ show userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -51,9 +52,8 @@ oauth2GitLabHostScopes host scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = host
|
, oauth2AuthorizeEndpoint =
|
||||||
`withPath` "/oauth/authorize"
|
host `withPath` "/oauth/authorize" `withQuery` [scopeParam " " scopes]
|
||||||
`withQuery` [scopeParam " " scopes]
|
|
||||||
, oauth2TokenEndpoint = host `withPath` "/oauth/token"
|
, oauth2TokenEndpoint = host `withPath` "/oauth/token"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@ -69,7 +69,8 @@ oauth2GoogleScopedWidget widget scopes clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://www.googleapis.com/oauth2/v3/userinfo"
|
"https://www.googleapis.com/oauth2/v3/userinfo"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = userId
|
, credsIdent = userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -77,7 +78,8 @@ oauth2GoogleScopedWidget widget scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://accounts.google.com/o/oauth2/auth"
|
, oauth2AuthorizeEndpoint =
|
||||||
|
"https://accounts.google.com/o/oauth2/auth"
|
||||||
`withQuery` [scopeParam " " scopes]
|
`withQuery` [scopeParam " " scopes]
|
||||||
, oauth2TokenEndpoint = "https://www.googleapis.com/oauth2/v3/token"
|
, oauth2TokenEndpoint = "https://www.googleapis.com/oauth2/v3/token"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
|
|||||||
@ -41,7 +41,8 @@ oauth2Nylas clientId clientSecret =
|
|||||||
|
|
||||||
either
|
either
|
||||||
(throwIO . YesodOAuth2Exception.JSONDecodingError pluginName)
|
(throwIO . YesodOAuth2Exception.JSONDecodingError pluginName)
|
||||||
(\(User userId) -> pure Creds { credsPlugin = pluginName
|
(\(User userId) -> pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = userId
|
, credsIdent = userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -51,11 +52,10 @@ oauth2Nylas clientId clientSecret =
|
|||||||
oauth = OAuth2
|
oauth = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://api.nylas.com/oauth/authorize"
|
, oauth2AuthorizeEndpoint =
|
||||||
|
"https://api.nylas.com/oauth/authorize"
|
||||||
`withQuery` [ ("response_type", "code")
|
`withQuery` [ ("response_type", "code")
|
||||||
, ( "client_id"
|
, ("client_id", encodeUtf8 clientId)
|
||||||
, encodeUtf8 clientId
|
|
||||||
)
|
|
||||||
-- N.B. The scopes delimeter is unknown/untested. Verify that before
|
-- N.B. The scopes delimeter is unknown/untested. Verify that before
|
||||||
-- extracting this to an argument and offering a Scoped function. In
|
-- extracting this to an argument and offering a Scoped function. In
|
||||||
-- its current state, it doesn't matter because it's only one scope.
|
-- its current state, it doesn't matter because it's only one scope.
|
||||||
|
|||||||
@ -61,7 +61,8 @@ salesforceHelper name profileUri authorizeUri tokenUri scopes clientId clientSec
|
|||||||
= authOAuth2 name oauth2 $ \manager token -> do
|
= authOAuth2 name oauth2 $ \manager token -> do
|
||||||
(User userId, userResponse) <- authGetProfile name manager token profileUri
|
(User userId, userResponse) <- authGetProfile name manager token profileUri
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = userId
|
, credsIdent = userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
|
|||||||
@ -56,7 +56,8 @@ oauth2SlackScoped scopes clientId clientSecret =
|
|||||||
|
|
||||||
either
|
either
|
||||||
(throwIO . YesodOAuth2Exception.JSONDecodingError pluginName)
|
(throwIO . YesodOAuth2Exception.JSONDecodingError pluginName)
|
||||||
(\(User userId) -> pure Creds { credsPlugin = pluginName
|
(\(User userId) -> pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = userId
|
, credsIdent = userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -66,10 +67,9 @@ oauth2SlackScoped scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://slack.com/oauth/authorize"
|
, oauth2AuthorizeEndpoint =
|
||||||
`withQuery` [ scopeParam ","
|
"https://slack.com/oauth/authorize"
|
||||||
$ map scopeText scopes
|
`withQuery` [scopeParam "," $ map scopeText scopes]
|
||||||
]
|
|
||||||
, oauth2TokenEndpoint = "https://slack.com/api/oauth.access"
|
, oauth2TokenEndpoint = "https://slack.com/api/oauth.access"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
}
|
}
|
||||||
|
|||||||
@ -26,7 +26,8 @@ oauth2Spotify scopes clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://api.spotify.com/v1/me"
|
"https://api.spotify.com/v1/me"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = userId
|
, credsIdent = userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -34,7 +35,8 @@ oauth2Spotify scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://accounts.spotify.com/authorize"
|
, oauth2AuthorizeEndpoint =
|
||||||
|
"https://accounts.spotify.com/authorize"
|
||||||
`withQuery` [scopeParam " " scopes]
|
`withQuery` [scopeParam " " scopes]
|
||||||
, oauth2TokenEndpoint = "https://accounts.spotify.com/api/token"
|
, oauth2TokenEndpoint = "https://accounts.spotify.com/api/token"
|
||||||
, oauth2RedirectUri = Nothing
|
, oauth2RedirectUri = Nothing
|
||||||
|
|||||||
@ -38,7 +38,8 @@ oauth2TwitchScoped scopes clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://id.twitch.tv/oauth2/validate"
|
"https://id.twitch.tv/oauth2/validate"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = userId
|
, credsIdent = userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
@ -46,9 +47,11 @@ oauth2TwitchScoped scopes clientId clientSecret =
|
|||||||
oauth2 = OAuth2
|
oauth2 = OAuth2
|
||||||
{ oauth2ClientId = clientId
|
{ oauth2ClientId = clientId
|
||||||
, oauth2ClientSecret = Just clientSecret
|
, oauth2ClientSecret = Just clientSecret
|
||||||
, oauth2AuthorizeEndpoint = "https://id.twitch.tv/oauth2/authorize"
|
, oauth2AuthorizeEndpoint =
|
||||||
|
"https://id.twitch.tv/oauth2/authorize"
|
||||||
`withQuery` [scopeParam " " scopes]
|
`withQuery` [scopeParam " " scopes]
|
||||||
, oauth2TokenEndpoint = "https://id.twitch.tv/oauth2/token"
|
, oauth2TokenEndpoint =
|
||||||
|
"https://id.twitch.tv/oauth2/token"
|
||||||
`withQuery` [ ("client_id", T.encodeUtf8 clientId)
|
`withQuery` [ ("client_id", T.encodeUtf8 clientId)
|
||||||
, ("client_secret", T.encodeUtf8 clientSecret)
|
, ("client_secret", T.encodeUtf8 clientSecret)
|
||||||
]
|
]
|
||||||
|
|||||||
@ -33,7 +33,8 @@ oauth2Upcase clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"http://upcase.com/api/v1/me.json"
|
"http://upcase.com/api/v1/me.json"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = T.pack $ show userId
|
, credsIdent = T.pack $ show userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
|
|||||||
@ -28,7 +28,8 @@ oauth2WordPressDotCom clientId clientSecret =
|
|||||||
token
|
token
|
||||||
"https://public-api.wordpress.com/rest/v1/me/"
|
"https://public-api.wordpress.com/rest/v1/me/"
|
||||||
|
|
||||||
pure Creds { credsPlugin = pluginName
|
pure Creds
|
||||||
|
{ credsPlugin = pluginName
|
||||||
, credsIdent = T.pack $ show userId
|
, credsIdent = T.pack $ show userId
|
||||||
, credsExtra = setExtra token userResponse
|
, credsExtra = setExtra token userResponse
|
||||||
}
|
}
|
||||||
|
|||||||
@ -21,8 +21,7 @@ spec = do
|
|||||||
"example.com" `shouldBe` Host "example.com"
|
"example.com" `shouldBe` Host "example.com"
|
||||||
|
|
||||||
describe "IsString URIRef Relative" $ it "works" $ do
|
describe "IsString URIRef Relative" $ it "works" $ do
|
||||||
"example.com/foo?bar=baz"
|
"example.com/foo?bar=baz" `shouldBe` [relativeRef|example.com/foo?bar=baz|]
|
||||||
`shouldBe` [relativeRef|example.com/foo?bar=baz|]
|
|
||||||
|
|
||||||
describe "IsString URIRef Absolute" $ it "works" $ do
|
describe "IsString URIRef Absolute" $ it "works" $ do
|
||||||
"https://example.com/foo?bar=baz"
|
"https://example.com/foo?bar=baz"
|
||||||
@ -62,7 +61,9 @@ spec = do
|
|||||||
uriWithQuery `shouldBe` [uri|http://example.com?foo=bar|]
|
uriWithQuery `shouldBe` [uri|http://example.com?foo=bar|]
|
||||||
|
|
||||||
it "handles a URI with an existing query" $ do
|
it "handles a URI with an existing query" $ do
|
||||||
let uriWithQuery = [uri|http://example.com?foo=bar|] `withQuery` [("baz", "bat")]
|
let
|
||||||
|
uriWithQuery =
|
||||||
|
[uri|http://example.com?foo=bar|] `withQuery` [("baz", "bat")]
|
||||||
|
|
||||||
uriWithQuery `shouldBe` [uri|http://example.com?foo=bar&baz=bat|]
|
uriWithQuery `shouldBe` [uri|http://example.com?foo=bar&baz=bat|]
|
||||||
|
|
||||||
@ -70,7 +71,9 @@ spec = do
|
|||||||
-- it's worthwhile to show that you don't (and can't) pre-sanitize when
|
-- it's worthwhile to show that you don't (and can't) pre-sanitize when
|
||||||
-- using this function.
|
-- using this function.
|
||||||
it "handles santization of the query" $ do
|
it "handles santization of the query" $ do
|
||||||
let uriWithQuery = [uri|http://example.com|] `withQuery` [("foo", "bar baz")]
|
let
|
||||||
|
uriWithQuery =
|
||||||
|
[uri|http://example.com|] `withQuery` [("foo", "bar baz")]
|
||||||
|
|
||||||
toText uriWithQuery `shouldBe` "http://example.com?foo=bar%20baz"
|
toText uriWithQuery `shouldBe` "http://example.com?foo=bar%20baz"
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user