Skip to content

Commit

Permalink
Merge pull request #20 from fpco/add-discover-uri
Browse files Browse the repository at this point in the history
Add discoverURI function
  • Loading branch information
chrisdone authored May 25, 2020
2 parents 235a5d6 + dd772b9 commit 61ec3f6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
0.2.3.1
=======

* Expose `discoverURI` in `Network.Wai.Middleware.Auth.OIDC`

0.2.3.0
=======

Expand Down
11 changes: 10 additions & 1 deletion src/Network/Wai/Middleware/Auth/OIDC.hs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ module Network.Wai.Middleware.Auth.OIDC
( -- * Creating a provider
OpenIDConnect
, discover
, discoverURI
-- * Customizing a provider
, oidcClientId
, oidcClientSecret
Expand Down Expand Up @@ -165,13 +166,21 @@ instance AuthProvider OpenIDConnect where
Just claims ->
pure (Just (storeClaims claims req, user))

-- | Fetch configuration for a provider from its discovery endpoint.
-- | Fetch configuration for a provider from its discovery
-- endpoint. Sets the path to @/.well-known/..@.
--
-- @since 0.2.3.0
discover :: T.Text -> IO OpenIDConnect
discover urlText = do
base <- parseAbsoluteURI urlText
let uri = base { U.uriPath = "/.well-known/openid-configuration" }
discoverURI uri

-- | Fetch configuration for a provider from an exact URI.
--
-- @since 0.2.3.1
discoverURI :: U.URI -> IO OpenIDConnect
discoverURI uri = do
metadata <- fetchMetadata uri
jwkset <- fetchJWKSet (jwksUri metadata)
pure OpenIDConnect
Expand Down
2 changes: 1 addition & 1 deletion wai-middleware-auth.cabal
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
cabal-version: 1.18
name: wai-middleware-auth
version: 0.2.3.0
version: 0.2.3.1
synopsis: Authentication middleware that secures WAI application
description: Please see the README and Haddocks at <https://www.stackage.org/package/wai-middleware-auth>
license: MIT
Expand Down

0 comments on commit 61ec3f6

Please sign in to comment.