mirror of
https://github.com/freckle/yesod-auth-oauth2.git
synced 2026-09-10 19:34:56 +02:00
Merge de690dd3b1 into 1dcbb2dbc1
This commit is contained in:
commit
7d20cbf4fd
@ -7,7 +7,7 @@
|
|||||||
-- * Returns name, access_token, email, avatar, team_id, and team_name as extras
|
-- * Returns name, access_token, email, avatar, team_id, and team_name as extras
|
||||||
--
|
--
|
||||||
module Yesod.Auth.OAuth2.Slack
|
module Yesod.Auth.OAuth2.Slack
|
||||||
( SlackScope(..)
|
( defaultSlackIdentityScopes
|
||||||
, oauth2Slack
|
, oauth2Slack
|
||||||
, oauth2SlackScoped
|
, oauth2SlackScoped
|
||||||
) where
|
) where
|
||||||
@ -26,10 +26,12 @@ import Network.HTTP.Conduit (Manager)
|
|||||||
import qualified Data.Text as Text
|
import qualified Data.Text as Text
|
||||||
import qualified Network.HTTP.Conduit as HTTP
|
import qualified Network.HTTP.Conduit as HTTP
|
||||||
|
|
||||||
data SlackScope
|
defaultSlackIdentityScopes :: [Text]
|
||||||
= SlackEmailScope
|
defaultSlackIdentityScopes =
|
||||||
| SlackTeamScope
|
[ "identity.email"
|
||||||
| SlackAvatarScope
|
, "identity.team"
|
||||||
|
, "identity.avatar"
|
||||||
|
]
|
||||||
|
|
||||||
data SlackUser = SlackUser
|
data SlackUser = SlackUser
|
||||||
{ slackUserId :: Text
|
{ slackUserId :: Text
|
||||||
@ -80,7 +82,7 @@ oauth2Slack clientId clientSecret = oauth2SlackScoped clientId clientSecret []
|
|||||||
oauth2SlackScoped :: YesodAuth m
|
oauth2SlackScoped :: YesodAuth m
|
||||||
=> Text -- ^ Client ID
|
=> Text -- ^ Client ID
|
||||||
-> Text -- ^ Client Secret
|
-> Text -- ^ Client Secret
|
||||||
-> [SlackScope]
|
-> [Text]
|
||||||
-> AuthPlugin m
|
-> AuthPlugin m
|
||||||
oauth2SlackScoped clientId clientSecret scopes =
|
oauth2SlackScoped clientId clientSecret scopes =
|
||||||
authOAuth2 "slack" oauth fetchSlackProfile
|
authOAuth2 "slack" oauth fetchSlackProfile
|
||||||
@ -95,12 +97,7 @@ oauth2SlackScoped clientId clientSecret scopes =
|
|||||||
, oauthAccessTokenEndpoint = "https://slack.com/api/oauth.access"
|
, oauthAccessTokenEndpoint = "https://slack.com/api/oauth.access"
|
||||||
, oauthCallback = Nothing
|
, oauthCallback = Nothing
|
||||||
}
|
}
|
||||||
scopeTexts = "identity.basic":map scopeText scopes
|
scopeTexts = "identity.basic":scopes
|
||||||
|
|
||||||
scopeText :: SlackScope -> Text
|
|
||||||
scopeText SlackEmailScope = "identity.email"
|
|
||||||
scopeText SlackTeamScope = "identity.team"
|
|
||||||
scopeText SlackAvatarScope = "identity.avatar"
|
|
||||||
|
|
||||||
fetchSlackProfile :: Manager -> AccessToken -> IO (Creds m)
|
fetchSlackProfile :: Manager -> AccessToken -> IO (Creds m)
|
||||||
fetchSlackProfile manager token = do
|
fetchSlackProfile manager token = do
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user