Commit e53f2cb
committed
OAuth2 - PKCE
* Add a `pkce` option to the oauth2 strategy that defaults
to `false`.
* When the option is true, the client will authorize with the
provider using PKCE (proof key for code exchange) [1]. This
enhances the security footprint of the interaction and is now
recommended by the IETF for all OAuth2 code grant interactions.
* At a high level, PKCE works as follows:
1. Generate a new random code verifier string value with a
minimum length of 43 characters and a maximum length of
128 characters.
2. Take the SHA256 hash value of the code verifier string and
perform a URL-safe Base64 encode of the result as defined
in [2].
3. Pass `code_challenge={Base64(SHA256(code_verifier)}`
and `code_challenge_method=S256` query parameters with
the client OAuth2 authorize request.
4. In the callback_phase, pass the `code_verifier` in plaintext
to the provider as a query parameter to the OAuth2 token
endpoint. This provides strong guarantees to the OAuth provider
that the client is the same entity that requested authorization.
[1]: https://tools.ietf.org/html/rfc7636
[2]: https://tools.ietf.org/html/rfc7636#appendix-A1 parent 35bc27b commit e53f2cb
File tree
2 files changed
+38
-4
lines changed- lib/omniauth/strategies
- spec/omniauth/strategies
2 files changed
+38
-4
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
| 32 | + | |
32 | 33 | | |
33 | 34 | | |
34 | 35 | | |
| |||
49 | 50 | | |
50 | 51 | | |
51 | 52 | | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
52 | 65 | | |
53 | 66 | | |
| 67 | + | |
54 | 68 | | |
55 | 69 | | |
56 | 70 | | |
57 | 71 | | |
| 72 | + | |
| 73 | + | |
58 | 74 | | |
59 | 75 | | |
60 | 76 | | |
61 | 77 | | |
62 | 78 | | |
63 | | - | |
| 79 | + | |
64 | 80 | | |
65 | 81 | | |
66 | 82 | | |
| |||
84 | 100 | | |
85 | 101 | | |
86 | 102 | | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
87 | 109 | | |
88 | 110 | | |
89 | 111 | | |
90 | 112 | | |
91 | 113 | | |
92 | 114 | | |
93 | | - | |
94 | | - | |
| 115 | + | |
95 | 116 | | |
96 | 117 | | |
97 | | - | |
98 | 118 | | |
99 | 119 | | |
100 | 120 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
69 | 76 | | |
70 | 77 | | |
71 | 78 | | |
| |||
80 | 87 | | |
81 | 88 | | |
82 | 89 | | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
83 | 97 | | |
84 | 98 | | |
85 | 99 | | |
| |||
0 commit comments