packages feed

yesod-auth-oauth2 0.6.1.0 → 0.6.1.1

raw patch · 3 files changed

+63/−3 lines, 3 filesPVP: minor bump suggested

API additions: PVP suggests at least a minor version bump

API changes (from Hackage documentation)

+ Yesod.Auth.OAuth2.AzureAD: instance Data.Aeson.Types.FromJSON.FromJSON Yesod.Auth.OAuth2.AzureAD.User
+ Yesod.Auth.OAuth2.AzureAD: oauth2AzureAD :: YesodAuth m => Text -> Text -> AuthPlugin m
+ Yesod.Auth.OAuth2.AzureAD: oauth2AzureADScoped :: YesodAuth m => [Text] -> Text -> Text -> AuthPlugin m

Files

CHANGELOG.md view
@@ -1,6 +1,12 @@-## [*Unreleased*](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.6.1.0...master)+## [*Unreleased*](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.6.1.1...master)  None++## [v0.6.1.1](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.6.1.0...v0.6.1.1)++- Added AzureAD provider+- COMPATIBILITY: Use `hoauth2-1.8.1`+- COMPATIBILITY: Test with GHC 8.6.3, and not 8.2  ## [v0.6.1.0](https://github.com/thoughtbot/yesod-auth-oauth2/compare/v0.6.0.0...v0.6.1.0) 
+ src/Yesod/Auth/OAuth2/AzureAD.hs view
@@ -0,0 +1,53 @@+{-# LANGUAGE OverloadedStrings #-}+-- |+--+-- OAuth2 plugin for Azure AD.+--+-- * Authenticates against Azure AD+-- * Uses email as credentials identifier+--+module Yesod.Auth.OAuth2.AzureAD+    ( oauth2AzureAD+    , oauth2AzureADScoped+    ) where++import Prelude+import Yesod.Auth.OAuth2.Prelude++newtype User = User Text++instance FromJSON User where+    parseJSON = withObject "User" $ \o -> User+        <$> o .: "mail"++pluginName :: Text+pluginName = "azuread"++defaultScopes :: [Text]+defaultScopes = ["openid", "profile"]++oauth2AzureAD :: YesodAuth m => Text -> Text -> AuthPlugin m+oauth2AzureAD = oauth2AzureADScoped defaultScopes++oauth2AzureADScoped :: YesodAuth m => [Text] -> Text -> Text -> AuthPlugin m+oauth2AzureADScoped scopes clientId clientSecret =+    authOAuth2 pluginName oauth2 $ \manager token -> do+        (User userId, userResponse) <-+            authGetProfile pluginName manager token "https://graph.microsoft.com/v1.0/me"++        pure Creds+            { credsPlugin = pluginName+            , credsIdent = userId+            , credsExtra = setExtra token userResponse+            }+  where+    oauth2 = OAuth2+        { oauthClientId = clientId+        , oauthClientSecret = clientSecret+        , oauthOAuthorizeEndpoint = "https://login.windows.net/common/oauth2/authorize" `withQuery`+            [ scopeParam "," scopes+            , ("resource", "https://graph.microsoft.com")+            ]+        , oauthAccessTokenEndpoint = "https://login.windows.net/common/oauth2/token"+        , oauthCallback = Nothing+        }
yesod-auth-oauth2.cabal view
@@ -4,10 +4,10 @@ -- -- see: https://github.com/sol/hpack ----- hash: ee9d146c23aee38467708f39f42603877123800b2d17071c147e1b3e85f2551b+-- hash: c1c011a70a950aa06a81581631093cff63155d27dfd919ee890ec488597e5bd0  name:           yesod-auth-oauth2-version:        0.6.1.0+version:        0.6.1.1 synopsis:       OAuth 2.0 authentication plugins description:    Library to authenticate with OAuth 2.0 for Yesod web applications. category:       Web@@ -54,6 +54,7 @@   exposed-modules:       URI.ByteString.Extension       Yesod.Auth.OAuth2+      Yesod.Auth.OAuth2.AzureAD       Yesod.Auth.OAuth2.BattleNet       Yesod.Auth.OAuth2.Bitbucket       Yesod.Auth.OAuth2.Dispatch