Skip to content

Commit c3eb8d2

Browse files
authored
Merge pull request #21 from fpco/fix-oauth2-scopes
Fix oauth2 scope specification
2 parents 61ec3f6 + 9657e1f commit c3eb8d2

File tree

4 files changed

+38
-46
lines changed

4 files changed

+38
-46
lines changed

CHANGELOG.md

Lines changed: 34 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,58 @@
1-
0.2.3.1
2-
=======
1+
# 0.2.3.1
32

4-
* Expose `discoverURI` in `Network.Wai.Middleware.Auth.OIDC`
3+
- Expose `discoverURI` in `Network.Wai.Middleware.Auth.OIDC`
4+
- Fix bug with OAuth2 and OpenID Connect authentication where scopes were
5+
separated using comma's instead of spaces.
56

6-
0.2.3.0
7-
=======
7+
# 0.2.3.0
88

9-
* Support `hoauth2-1.11.0`
10-
* Drop support for `jose` versions < 0.8
11-
* Expose `decodeKey`
12-
* OAuth2 provider remove a session when an access token expires. It will use a
9+
- Support `hoauth2-1.11.0`
10+
- Drop support for `jose` versions < 0.8
11+
- Expose `decodeKey`
12+
- OAuth2 provider remove a session when an access token expires. It will use a
1313
refresh token if one is available to create a new session. If no refresh token
1414
is available it will redirect the user to re-authenticate.
15-
* Providers can define logic for refreshing a session without user intervention.
16-
* Add an OpenID Connect provider.
15+
- Providers can define logic for refreshing a session without user intervention.
16+
- Add an OpenID Connect provider.
1717

18-
0.2.2.0
19-
=======
18+
# 0.2.2.0
2019

21-
* Add request logging to executable
22-
* Newer multistage Docker build system
20+
- Add request logging to executable
21+
- Newer multistage Docker build system
2322

24-
0.2.1.0
25-
=======
23+
# 0.2.1.0
2624

27-
* Fix a bug in deserialization of `UserIdentity`
25+
- Fix a bug in deserialization of `UserIdentity`
2826

29-
0.2.0.0
30-
=======
27+
# 0.2.0.0
3128

32-
* Drop compatiblity with hoauth2 versions <= 1.0.0.
33-
* Add a function for getting the oauth2 token from an authenticated request.
34-
* Modify encoding of oauth2 session cookies. As a consequence existing cookies will be invalid.
29+
- Drop compatiblity with hoauth2 versions <= 1.0.0.
30+
- Add a function for getting the oauth2 token from an authenticated request.
31+
- Modify encoding of oauth2 session cookies. As a consequence existing cookies will be invalid.
3532

36-
0.1.2.1
37-
=======
33+
# 0.1.2.1
3834

39-
* Compatibility with hoauth2-1.3.0 - fixed: [#4](https://github.com/fpco/wai-middleware-auth/issues/4)
35+
- Compatibility with hoauth2-1.3.0 - fixed: [#4](https://github.com/fpco/wai-middleware-auth/issues/4)
4036

41-
0.1.2.0
42-
=======
37+
# 0.1.2.0
4338

44-
* Implemented compatibility with hoauth2 >= 1.0.0 - fixed: [#3](https://github.com/fpco/wai-middleware-auth/issues/3)
39+
- Implemented compatibility with hoauth2 >= 1.0.0 - fixed: [#3](https://github.com/fpco/wai-middleware-auth/issues/3)
4540

46-
0.1.1.2
47-
=======
41+
# 0.1.1.2
4842

49-
* Fixed [wai-middleware-auth-0.1.1.1 does not compile in 32 bit Linux](https://github.com/fpco/wai-middleware-auth/issues/2)
43+
- Fixed [wai-middleware-auth-0.1.1.1 does not compile in 32 bit Linux](https://github.com/fpco/wai-middleware-auth/issues/2)
5044

51-
0.1.1.1
52-
=======
45+
# 0.1.1.1
5346

54-
* Disallow empty `userIdentity` to produce a successfull login.
55-
* Produces a 404 on `/favicon.ico` page if not logged in: work around for issue
47+
- Disallow empty `userIdentity` to produce a successfull login.
48+
- Produces a 404 on `/favicon.ico` page if not logged in: work around for issue
5649
with Chrome requesting it first and messing up the redirect url.
57-
* Added JQuery to the template, since it's bootstrap's requirement.
50+
- Added JQuery to the template, since it's bootstrap's requirement.
5851

59-
0.1.1.0
60-
=======
52+
# 0.1.1.0
6153

62-
* Fixed whitelist email regex matching for Github and Google auth.
54+
- Fixed whitelist email regex matching for Github and Google auth.
6355

64-
0.1.0.0
65-
=======
56+
# 0.1.0.0
6657

67-
* Initial implementation.
58+
- Initial implementation.

src/Network/Wai/Auth/Internal.hs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,8 @@ oauth2Login
7676
oauth2Login oauth2 man oa2Scope providerName req suffix onSuccess onFailure =
7777
case suffix of
7878
[] -> do
79-
let scope = (encodeUtf8 . T.intercalate ",") <$> oa2Scope
79+
-- https://tools.ietf.org/html/rfc6749#section-3.3
80+
let scope = (encodeUtf8 . T.intercalate " ") <$> oa2Scope
8081
let redirectUrl =
8182
getRedirectURI $
8283
appendQueryParams

test/Spec/Network/Wai/Middleware/Auth/OAuth2.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ tests = testGroup "Network.Wai.Auth.OAuth2"
4242
assertStatus 303 redirect3
4343
assertHeader
4444
"location"
45-
(TE.encodeUtf8 host <> "/authorize?scope=scope1%2Cscope2&client_id=client-id&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fprefix%2Foauth2%2Fcomplete")
45+
(TE.encodeUtf8 host <> "/authorize?scope=scope1%20scope2&client_id=client-id&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fprefix%2Foauth2%2Fcomplete")
4646
redirect3
4747

4848
, testCase "when a request is made with a valid session then pass the request through" $

test/Spec/Network/Wai/Middleware/Auth/OIDC.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ tests = testGroup "Network.Wai.Auth.OIDC"
4343
assertStatus 303 redirect3
4444
assertHeader
4545
"location"
46-
(TE.encodeUtf8 host <> "/authorize?scope=openid%2Cscope1&client_id=client-id&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fprefix%2Foidc%2Fcomplete")
46+
(TE.encodeUtf8 host <> "/authorize?scope=openid%20scope1&client_id=client-id&response_type=code&redirect_uri=http%3A%2F%2Flocalhost%2Fprefix%2Foidc%2Fcomplete")
4747
redirect3
4848

4949
, testCase "when a request is made with a valid session then pass the request through" $

0 commit comments

Comments
 (0)