rodauth-oauth 0.0.4 → 0.3.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 22808f6f421ce935e5f69301b1f0edc37a286baedf0c4a4039d29b3ff678bf40
4
- data.tar.gz: 64305ba438e3035309ca428d4820f00f7b169ca219882575262ee8242a800f50
3
+ metadata.gz: 24f3563d467a065dc119cbe53c0f14c8f28654d6512de0b7fd09a99e3f4aabdb
4
+ data.tar.gz: 8abc6dc62b463885f7198cafec57fe707f99885e67754be1d7cefbbefa31a834
5
5
  SHA512:
6
- metadata.gz: c6302e1e592bf760b9a1a1ac4adc6e9189545f58818553ec85fda0f86299531dcea1e1b59cba65aaa62d607e2cf541fb18ee2a9c2161ce96678b5b2812326a0b
7
- data.tar.gz: 689a8e88d89c8fe74b665c65138ff8372cee05d0783e473e8e124b9a9f21d9806bb397d185edf9d0c87ef21cfcd2d81bfa16ab0aaa3da64b9b28d6e5e2e24ab3
6
+ metadata.gz: 9fd172c9930f1cf88239a8f5ba7d5c93dc9c92b05a601c6f909b5ad12e4319ce0aa093831b93dad93542fdda0cdc1694b001ca78922239e80a2370472373b9a5
7
+ data.tar.gz: 26e8e9c619425213f2cd5f21e7710f9561c0b0395bd8928656584c88586f4197bf80a765d9a90baea604ef9fdaff5c27f4b8447adf3fa617463e26b7b0a08470
@@ -2,7 +2,194 @@
2
2
 
3
3
  ## master
4
4
 
5
- ## 0.0.4 (13/6/2020)
5
+ ### 0.3.0
6
+
7
+ #### Features
8
+
9
+ * `oauth_refresh_token_protection_policy` is a new option, which can be used to set a protection policy around usage of refresh tokens. By default it's `none`, for backwards-compatibility. However, when set to `rotation`, refresh tokens will be "use-once", i.e. a token refresh request will generate a new refresh token. Also, refresh token requests doen with already-used refresh tokens will be interpreted as a security breach, i.e. all tokens linked to the compromised refresh token will be revoked.
10
+
11
+ #### Improvements
12
+
13
+
14
+ * Support for the OIDC authorize [`prompt` parameter](https://openid.net/specs/openid-connect-core-1_0.html) (sectionn 3.1.2.1). It supports the `none`, `login` and `consent` out-of-the-box, while providing support for `select-account` when paired with [rodauth-select-account, a rodauth feature to handle multiple accounts in the same session](https://gitlab.com/honeyryderchuck/rodauth-select-account).
15
+
16
+ * Refresh Tokens are now expired. The refresh token expiration period is governed by the `oauth_refresh_token_expires_in` option (default: 1 year), and is the period for which a refresh token can be used after its respective token expired.
17
+
18
+ #### Bugfixes
19
+
20
+ * Default Templates now being packaged, as a way to provide a default experience to the OAuth journeys.
21
+
22
+ * fixing metadata urls when plugin loaded with a prefix path (@ianks)
23
+
24
+ * All date/time-based calculations, such as determining an expiration date, or checking if a token has expired, are now performed using database arithmetic operations, using sequel's `date_arithmetic` plugin. This will eliminate subtle bugs, such as when the database timezone is different than the application OS timezone.
25
+
26
+ * OIDC configuration endpoint is now stricter, eliminating JSON metadata inherited from the Oauth metadata endpoint. (@ianks)
27
+
28
+ #### Chore
29
+
30
+ Use `rodauth.convert_timestamp` in the templates, whenever dates are displayed.
31
+
32
+ Set HTTP Cache headers for metadata responses, such as `/.well-known/oauth-authorization-server` and `/.well-known/openid-configuration`, so they can be stored at the edge. The cache will be valid for 1 day (this value isn't set by an option yet).
33
+
34
+ ### 0.2.0
35
+
36
+ #### Features
37
+
38
+ ##### SAML Assertion Grant Type
39
+
40
+ `rodauth-auth` now supports using a SAML Assertion to request for an Access token.In order to enable, you have to:
41
+
42
+ ```ruby
43
+ plugin :rodauth do
44
+ enable :oauth_saml
45
+ end
46
+ ```
47
+
48
+ For more info about integrating it, [check the wiki](https://gitlab.com/honeyryderchuck/rodauth-oauth/-/wikis/SAML-Assertion-Access-Tokens).
49
+
50
+ ##### Supporting rotating keys
51
+
52
+ At some point, you'll want to replace the pkeys and algorithm used to generate and verify the JWT access tokens, but you want to keep validating previously-distributed JWT tokens, at least until they expire. Now you can, via two new options, `oauth_jwt_legacy_public_key` and `oauth_jwt_legacy_algorithm`, which will be declared in the JWKs URI and used to verify access tokens.
53
+
54
+
55
+ ##### Reuse access tokens
56
+
57
+ If the `oauth_reuse_access_token` is set, if there's already an existing valid access token, any new grant for the same application / account / scope will keep the same access token. This can be helpful in scenarios where one wants the same access token distributed across devices.
58
+
59
+ ##### require_authorizable_account
60
+
61
+ The method used to verify access to the authorize flow is called `require_authorizable_account`. By default, it checks if a user is logged in by using rodauth's own `require_account`. This is the method you'd want to redefine in order to augment these requirements, i.e. request 2fa authentication.
62
+
63
+ #### Improvements
64
+
65
+ Expired and revoked access tokens end up generating a lot of garbage, which will have to be periodically cleaned up. You can mitigate this now by setting a uniqueness index for a group of columns, i.e. if you set a uniqueness index for the `oauth_application_id/account_id/scopes` column, `rodauth-oauth` will transparently reuse the same db entry to store the new access token. If setting some other type of uniqueness index, make sure to update the option `oauth_tokens_unique_columns` (the array of columns from the uniqueness index).
66
+
67
+ #### Bugfixes
68
+
69
+ Calling `before_*_route` callbacks appropriately.
70
+
71
+ Fixed some mishandling of HTTP headers when in in resource-server mode.
72
+
73
+ #### Chore
74
+
75
+ * 97.7% test coverage;
76
+ * `rodauth-oauth` CI tests run against sqlite, postgresql and mysql.
77
+
78
+ ### 0.1.0
79
+
80
+ (31/7/2020)
81
+
82
+ #### Features
83
+
84
+ ##### OpenID
85
+
86
+ `rodauth-oauth` now ships with support for [OpenID Connect](https://openid.net/connect/). In order to enable, you have to:
87
+
88
+ ```ruby
89
+ plugin :rodauth do
90
+ enable :oidc
91
+ end
92
+ ```
93
+
94
+ For more info about integrating it, [check the wiki](https://gitlab.com/honeyryderchuck/rodauth-oauth/-/wikis/home#openid-connect-since-v01).
95
+
96
+ It supports omniauth openID integrations out-of-the-box, [check the OpenID example, which integrates with omniauth_openid_connect](https://gitlab.com/honeyryderchuck/rodauth-oauth/-/tree/master/examples).
97
+
98
+ #### Improvements
99
+
100
+ * JWT: `sub` claim now also handles "pairwise" subjects. For that, you have to set the `oauth_jwt_subject_type` option (`"public"` or `"pairwise"`) and `oauth_jwt_subject_secret` (will be used for salting the `sub` when the type is `"pairwise"`).
101
+ * JWT: `auth_time` claim is now supported; if your application uses the `rodauth` feature `:account_expiration`, it'll use the `last_account_login_at` method, otherwise you can set the `last_account_login_at` option:
102
+
103
+ ```ruby
104
+ last_account_login_at do
105
+ convert_timestamp(db[accounts_table].where(account_id_column => account_id).get(:that_column_where_you_keep_the_data))
106
+ end
107
+ ```
108
+ * JWT: `iss` claim now defaults to `authorization_server_url` when not defined;
109
+ * JWT: `aud` claim now defaults to the token application's client ID (`client_id` claim was removed as a result);
110
+
111
+
112
+
113
+ #### Breaking Changes
114
+
115
+ `rodauth-oauth` URLs no longer have the `oauth-` prefix, so make sure you update your integrations accordingly, i.e. where you used to rely on `/oauth-authorize`, you'll have to use `/authorize`.
116
+
117
+ URI schemes for client applications redirect URIs have to be `https`. In order to override this, set the `oauth_valid_uri_schemes` to an array of your expected URI schemes.
118
+
119
+
120
+ #### Bugfixes
121
+
122
+ * Authorization request submission can receive the `scope` as an array of values now, instead of only dealing with receiving a white-space separated list.
123
+ * fixed trailing "/" in the "issuer" value in server metadata (`https://server.com/` -> `https://server.com`).
124
+
125
+
126
+ ### 0.0.6
127
+
128
+ (6/7/2020)
129
+
130
+ #### Features
131
+
132
+ The `oauth_jwt` feature now supports JWT Secured Authorization Request (JAR) (see https://tools.ietf.org/html/draft-ietf-oauth-jwsreq-20). This means that client applications can send the authorization parameters inside a signed JWT. The client applications keeps the private key, while the authorization server **must** store a public key for the client application. For encrypted JWTs, the client application should use one of the public encryption keys exposed in the JWKs URI, to encrypt the JWT. Remember, **tokens must be signed then encrypted** (or just signed).
133
+
134
+ ###### Options:
135
+
136
+ * `:oauth_application_jws_jwk_column`: db column where the public key is stored; since it's stored in the JWS format, it can be stored either as a String (JSON-encoded), or as an hstore (if you're using postgresql);
137
+ * `:oauth_jwt_jwe_key`: key used to decrypt the request JWT;
138
+ * `:oauth_jwt_jwe_public_key`: key used to encrypt the request JWT, and which will be exposed in the JWKs URI in the JWK format;
139
+
140
+
141
+ #### Improvements
142
+
143
+ * Removing all `_param` options; these defined the URL params, however we're using protocol-defined params, so it's unlikely (and undesired) that these'll change.
144
+ * Hitting the revoke endpoint with a JWT access token returns a 400 error;
145
+
146
+ #### Chore
147
+
148
+ Removed React Javascript from example applications.
149
+
150
+
151
+ ### 0.0.5
152
+
153
+ (26/6/2020)
154
+
155
+ #### Features
156
+
157
+ * new option: `oauth_scope_separator` (default: `" "`), to define how scopes are stored;
158
+
159
+ ##### Resource Server mode
160
+
161
+ `rodauth-oauth` can now be used in a resource server, i.e. only for authorizing access to resources:
162
+
163
+
164
+ ```ruby
165
+ plugin :rodauth do
166
+ enable :oauth
167
+
168
+ is_authorization_server? false
169
+ authorization_server_url "https://auth-server"
170
+ end
171
+ ```
172
+
173
+ It **requires** the authorization to implement the server metadata endpoint (`/.well-known/oauth-authorization-server`), and if using JWS, the JWKs URI endpoint (unless `oauth_jwt_public_key` is defined).
174
+
175
+ #### Improvements
176
+
177
+ * Multiple Redirect URIs are now allowed for client applications out-of-the-box. In order to use it in API mode, you can pass the `redirect_uri` with an array of strings (the URLs) as values; in the new client application form, you can add several input fields with name field as `redirect_uri[]`. **ATTENTION!!** When using multiple redirect URIs, passing the desired redirect URI to the authorize form becomes mandatory.
178
+ * store scopes with whitespace instead of comma; set separator as `oauth_scope_separator` option, to keep backwards-compatibility;
179
+ * client application can now store multiple redirect uris; the POST API parameters can accept the redirect_uri param value both as a string or an array of string; internally, they'll be stored in a whitespace-separated string;
180
+
181
+ #### Bugfixes
182
+
183
+ * Fixed `RETURNING` support in the databases supporting it (such as postgres).
184
+
185
+ #### Chore
186
+
187
+ * option `scopes_param` renamed to `scope_param`;
188
+ *
189
+
190
+ ## 0.0.4
191
+
192
+ (13/6/2020)
6
193
 
7
194
  ### Features
8
195
 
@@ -39,7 +226,9 @@ The `oauth_jwt` feature now allows the usage of access tokens to authorize the g
39
226
 
40
227
  * Fixed scope claim of JWT ("scopes" -> "scope");
41
228
 
42
- ## 0.0.3 (5/6/2020)
229
+ ## 0.0.3
230
+
231
+ (5/6/2020)
43
232
 
44
233
  ### Features
45
234
 
@@ -71,7 +260,9 @@ end
71
260
  * renamed the existing `use_oauth_implicit_grant_type` to `use_oauth_implicit_grant_type?`;
72
261
  * It's now usable as JSON API (small caveat: POST authorize will still redirect on success...);
73
262
 
74
- ## 0.0.2 (29/5/2020)
263
+ ## 0.0.2
264
+
265
+ (29/5/2020)
75
266
 
76
267
  ### Features
77
268
 
@@ -87,6 +278,8 @@ end
87
278
 
88
279
  * usage of client secret for authorizing the generation of tokens, as the spec mandates (and refraining from them when doing PKCE).
89
280
 
90
- ## 0.0.1 (14/5/2020)
281
+ ## 0.0.1
282
+
283
+ (14/5/2020)
91
284
 
92
285
  Initial implementation of the Oauth 2.0 framework, with an example app done using roda.
data/README.md CHANGED
@@ -1,13 +1,13 @@
1
1
  # Rodauth::Oauth
2
2
 
3
- [![pipeline status](https://gitlab.com/honeyryderchuck/rodauth-oauth/badges/master/pipeline.svg)](https://gitlab.com/honeyryderchuck/rodauth-oauth/-/commits/master)
4
- [![coverage report](https://gitlab.com/honeyryderchuck/rodauth-oauth/badges/master/coverage.svg)](https://gitlab.com/honeyryderchuck/rodauth-oauth/-/commits/master)
3
+ [![pipeline status](https://gitlab.com/honeyryderchuck/rodauth-oauth/badges/master/pipeline.svg)](https://gitlab.com/honeyryderchuck/rodauth-oauth/-/pipelines?page=1&ref=master)
4
+ [![coverage report](https://gitlab.com/honeyryderchuck/rodauth-oauth/badges/master/coverage.svg?job=coverage)](https://honeyryderchuck.gitlab.io/rodauth-oauth/coverage/#_AllFiles)
5
5
 
6
6
  This is an extension to the `rodauth` gem which implements the [OAuth 2.0 framework](https://tools.ietf.org/html/rfc6749) for an authorization server.
7
7
 
8
8
  ## Features
9
9
 
10
- This gem implements:
10
+ This gem implements the following RFCs and features of OAuth:
11
11
 
12
12
  * [The OAuth 2.0 protocol framework](https://tools.ietf.org/html/rfc6749):
13
13
  * [Authorization grant flow](https://tools.ietf.org/html/rfc6749#section-1.3);
@@ -21,8 +21,12 @@ This gem implements:
21
21
  * Access Type (Token refresh online and offline);
22
22
  * [MAC Authentication Scheme](https://tools.ietf.org/html/draft-hammer-oauth-v2-mac-token-02);
23
23
  * [JWT Acess Tokens](https://tools.ietf.org/html/draft-ietf-oauth-access-token-jwt-07);
24
+ * [SAML 2.0 Assertion Access Tokens](https://tools.ietf.org/html/draft-ietf-oauth-saml2-bearer-03);
25
+ * [JWT Secured Authorization Requests](https://tools.ietf.org/html/draft-ietf-oauth-jwsreq-20);
24
26
  * OAuth application and token management dashboards;
25
27
 
28
+ It also implements the [OpenID Connect layer](https://openid.net/connect/) on top of the OAuth features it provides.
29
+
26
30
  This gem supports also rails (through [rodauth-rails]((https://github.com/janko/rodauth-rails))).
27
31
 
28
32
 
@@ -42,6 +46,15 @@ Or install it yourself as:
42
46
 
43
47
  $ gem install rodauth-oauth
44
48
 
49
+
50
+ ## Resources
51
+ | | |
52
+ | ------------- | ----------------------------------------------------------- |
53
+ | Website | https://honeyryderchuck.gitlab.io/rodauth-oauth/ |
54
+ | Documentation | https://honeyryderchuck.gitlab.io/rodauth-oauth/rdoc/ |
55
+ | Wiki | https://gitlab.com/honeyryderchuck/rodauth-oauth/wikis/home |
56
+ | CI | https://gitlab.com/honeyryderchuck/rodauth-oauth/pipelines |
57
+
45
58
  ## Usage
46
59
 
47
60
  This tutorial assumes you already read the documentation and know how to set up `rodauth`. After that, integrating `roda-auth` will look like:
@@ -85,11 +98,22 @@ route do |r|
85
98
  end
86
99
  ```
87
100
 
88
- You'll have to do a bit more boilerplate, so here's the instructions.
101
+
102
+ For OpenID, it's very similar to the example above:
103
+
104
+ ```ruby
105
+ plugin :rodauth do
106
+ # enable it in the plugin
107
+ enable :login, :openid
108
+ oauth_application_default_scope %w[openid]
109
+ oauth_application_scopes %w[openid email profile]
110
+ end
111
+ ```
112
+
89
113
 
90
114
  ### Example (TL;DR)
91
115
 
92
- If you're familiar with the technology and want to skip the next paragraphs, just [check our roda example](https://gitlab.com/honeyryderchuck/rodauth-oauth/-/tree/master/examples/roda).
116
+ If you're familiar with the technology and want to skip the next paragraphs, just [check our example applications](https://gitlab.com/honeyryderchuck/rodauth-oauth/-/tree/master/examples/).
93
117
 
94
118
 
95
119
  Generating tokens happens mostly server-to-server, so here's an example using:
@@ -100,7 +124,7 @@ Generating tokens happens mostly server-to-server, so here's an example using:
100
124
 
101
125
  ```ruby
102
126
  require "httpx"
103
- response = HTTPX.post("https://auth_server/oauth-token",json: {
127
+ response = HTTPX.post("https://auth_server/token",json: {
104
128
  client_id: ENV["OAUTH_CLIENT_ID"],
105
129
  client_secret: ENV["OAUTH_CLIENT_SECRET"],
106
130
  grant_type: "authorization_code",
@@ -114,7 +138,7 @@ puts payload #=> {"access_token" => "awr23f3h8f9d2h89...", "refresh_token" => "2
114
138
  ##### cURL
115
139
 
116
140
  ```
117
- > curl --data '{"client_id":"$OAUTH_CLIENT_ID","client_secret":"$OAUTH_CLIENT_SECRET","grant_type":"authorization_code","code":"oiweicnewdh32fhoi3hf3ihfo2ih3f2o3as"}' https://auth_server/oauth-token
141
+ > curl --data '{"client_id":"$OAUTH_CLIENT_ID","client_secret":"$OAUTH_CLIENT_SECRET","grant_type":"authorization_code","code":"oiweicnewdh32fhoi3hf3ihfo2ih3f2o3as"}' https://auth_server/token
118
142
  ```
119
143
 
120
144
  #### Refresh Token
@@ -125,7 +149,7 @@ Refreshing expired tokens also happens mostly server-to-server, here's an exampl
125
149
 
126
150
  ```ruby
127
151
  require "httpx"
128
- response = HTTPX.post("https://auth_server/oauth-token",json: {
152
+ response = HTTPX.post("https://auth_server/token",json: {
129
153
  client_id: ENV["OAUTH_CLIENT_ID"],
130
154
  client_secret: ENV["OAUTH_CLIENT_SECRET"],
131
155
  grant_type: "refresh_token",
@@ -139,7 +163,7 @@ puts payload #=> {"access_token" => "awr23f3h8f9d2h89...", "token_type" => "Bear
139
163
  ##### cURL
140
164
 
141
165
  ```
142
- > curl -H "X-your-auth-scheme: $SERVER_KEY" --data '{"client_id":"$OAUTH_CLIENT_ID","client_secret":"$OAUTH_CLIENT_SECRET","grant_type":"token","token":"2r89hfef4j9f90d2j2390jf390g"}' https://auth_server/oauth-token
166
+ > curl -H "X-your-auth-scheme: $SERVER_KEY" --data '{"client_id":"$OAUTH_CLIENT_ID","client_secret":"$OAUTH_CLIENT_SECRET","grant_type":"token","token":"2r89hfef4j9f90d2j2390jf390g"}' https://auth_server/token
143
167
  ```
144
168
 
145
169
  #### Revoking tokens
@@ -150,7 +174,7 @@ Token revocation can be done both by the idenntity owner or the application owne
150
174
  require "httpx"
151
175
  httpx = HTTPX.plugin(:basic_authorization)
152
176
  response = httpx.basic_authentication(ENV["CLIENT_ID"], ENV["CLIENT_SECRET"])
153
- .post("https://auth_server/oauth-revoke",json: {
177
+ .post("https://auth_server/revoke",json: {
154
178
  token_type_hint: "access_token", # can also be "refresh:tokn"
155
179
  token: "2r89hfef4j9f90d2j2390jf390g"
156
180
  })
@@ -162,7 +186,7 @@ puts payload #=> {"access_token" => "awr23f3h8f9d2h89...", "token_type" => "Bear
162
186
  ##### cURL
163
187
 
164
188
  ```
165
- > curl -H "X-your-auth-scheme: $SERVER_KEY" --data '{"client_id":"$OAUTH_CLIENT_ID","token_type_hint":"access_token","token":"2r89hfef4j9f90d2j2390jf390g"}' https://auth_server/oauth-revoke
189
+ > curl -H "X-your-auth-scheme: $SERVER_KEY" --data '{"client_id":"$OAUTH_CLIENT_ID","token_type_hint":"access_token","token":"2r89hfef4j9f90d2j2390jf390g"}' https://auth_server/revoke
166
190
  ```
167
191
 
168
192
  #### Token introspection
@@ -173,7 +197,7 @@ Token revocation can be used to determine the state of a token (whether active,
173
197
  require "httpx"
174
198
  httpx = HTTPX.plugin(:basic_authorization)
175
199
  response = httpx.basic_authentication(ENV["CLIENT_ID"], ENV["CLIENT_SECRET"])
176
- .post("https://auth_server/oauth-introspect",json: {
200
+ .post("https://auth_server/introspect",json: {
177
201
  token_type_hint: "access_token", # can also be "refresh:tokn"
178
202
  token: "2r89hfef4j9f90d2j2390jf390g"
179
203
  })
@@ -185,7 +209,7 @@ puts payload #=> {"active" => true, "scope" => "read write" ....
185
209
  ##### cURL
186
210
 
187
211
  ```
188
- > curl -H "X-your-auth-scheme: $SERVER_KEY" --data '{"client_id":"$OAUTH_CLIENT_ID","token_type_hint":"access_token","token":"2r89hfef4j9f90d2j2390jf390g"}' https://auth_server/oauth-revoke
212
+ > curl -H "X-your-auth-scheme: $SERVER_KEY" --data '{"client_id":"$OAUTH_CLIENT_ID","token_type_hint":"access_token","token":"2r89hfef4j9f90d2j2390jf390g"}' https://auth_server/revoke
189
213
  ```
190
214
 
191
215
  ### Authorization Server Metadata
@@ -242,10 +266,10 @@ The rodauth default setup expects the roda `render` plugin to be activated; by d
242
266
 
243
267
  Once you set it up, by default, the following endpoints will be available:
244
268
 
245
- * `GET /oauth-authorize`: Loads the OAuth authorization HTML form;
246
- * `POST /oauth-authorize`: Responds to an OAuth authorization request, as [per the spec](https://tools.ietf.org/html/rfc6749#section-4);
247
- * `POST /oauth-token`: Generates OAuth tokens as [per the spec](https://tools.ietf.org/html/rfc6749#section-4.4.2);
248
- * `POST /oauth-revoke`: Revokes OAuth tokens as [per the spec](https://tools.ietf.org/html/rfc7009);
269
+ * `GET /authorize`: Loads the OAuth authorization HTML form;
270
+ * `POST /authorize`: Responds to an OAuth authorization request, as [per the spec](https://tools.ietf.org/html/rfc6749#section-4);
271
+ * `POST /token`: Generates OAuth tokens as [per the spec](https://tools.ietf.org/html/rfc6749#section-4.4.2);
272
+ * `POST /revoke`: Revokes OAuth tokens as [per the spec](https://tools.ietf.org/html/rfc7009);
249
273
 
250
274
  ### OAuth applications
251
275
 
@@ -425,7 +449,7 @@ The "Proof Key for Code Exchange by OAuth Public Clients" (aka PKCE) flow, which
425
449
  ```ruby
426
450
  # with httpx
427
451
  require "httpx"
428
- response = HTTPX.post("https://auth_server/oauth-token",json: {
452
+ response = HTTPX.post("https://auth_server/token",json: {
429
453
  client_id: ENV["OAUTH_CLIENT_ID"],
430
454
  grant_type: "authorization_code",
431
455
  code: "oiweicnewdh32fhoi3hf3ihfo2ih3f2o3as",
@@ -476,7 +500,7 @@ Generating an access token will deliver the following fields:
476
500
  ```ruby
477
501
  # with httpx
478
502
  require "httpx"
479
- response = httpx.post("https://auth_server/oauth-token",json: {
503
+ response = httpx.post("https://auth_server/token",json: {
480
504
  client_id: env["oauth_client_id"],
481
505
  client_secret: env["oauth_client_secret"],
482
506
  grant_type: "authorization_code",
@@ -575,7 +599,7 @@ which adds an extra layer of protection.
575
599
 
576
600
  #### JWKS URI
577
601
 
578
- A route is defined for getting the JWK Set in a JSON format; this is typically used by client applications, who need the JWK set to decode the JWT token. This URL is typically `https://oauth-server/oauth-jwks`.
602
+ A route is defined for getting the JWK Set in a JSON format; this is typically used by client applications, who need the JWK set to decode the JWT token. This URL is typically `https://oauth-server/jwks`.
579
603
 
580
604
  #### JWT Bearer as authorization grant
581
605
 
@@ -584,7 +608,7 @@ One can emit a new access token by using the bearer access token as grant. This
584
608
  ```ruby
585
609
  # with httpx
586
610
  require "httpx"
587
- response = httpx.post("https://auth_server/oauth-token",json: {
611
+ response = httpx.post("https://auth_server/token",json: {
588
612
  grant_type: "urn:ietf:params:oauth:grant-type:jwt-bearer",
589
613
  assertion: "eyJhbGciOiJIUzI1NiJ9.eyJzdWIiOjEsImlzcyI6IkV4YW1wbGUiLCJpYXQiOjE1OTIwMDk1MDEsImNsaWVudF9pZCI6IkNMSUVOVF9JRCIsImV4cCI6MTU5MjAxMzEwMSwiYXVkIjpudWxsLCJzY29wZSI6InVzZXIucmVhZCB1c2VyLndyaXRlIiwianRpIjoiOGM1NTVjMjdiOWRjNDdmOTcyNWRkYzBhMjk0NzA1ZTA4NzFkY2JlN2Q5ZTNlMmVkNGE1ZTBiOGZlNTZlYzcxMSJ9.AlxKRtE3ec0mtyBSDx4VseND4eC6cH5ubtv8gfYxxsc"
590
614
  })
@@ -29,7 +29,8 @@ class CreateRodauthOAuth < ActiveRecord::Migration<%= migration_version %>
29
29
  # uncomment to enable PKCE
30
30
  # t.string :code_challenge
31
31
  # t.string :code_challenge_method
32
-
32
+ # uncomment to use OIDC nonce
33
+ # t.string :nonce
33
34
  t.index(%i[oauth_application_id code], unique: true)
34
35
  end
35
36
 
@@ -42,18 +43,20 @@ class CreateRodauthOAuth < ActiveRecord::Migration<%= migration_version %>
42
43
  t.foreign_key :oauth_tokens, column: :oauth_token_id
43
44
  t.integer :oauth_application_id
44
45
  t.foreign_key :oauth_applications, column: :oauth_application_id
45
- t.string :token, null: false, token: true
46
+ t.string :token, null: false, token: true, unique: true
46
47
  # uncomment if setting oauth_tokens_token_hash_column
47
48
  # and delete the token column
48
- # t.string :token_hash, token: true
49
- t.string :refresh_token
49
+ # t.string :token_hash, token: true, unique: true
50
+ t.string :refresh_token, unique: true
50
51
  # uncomment if setting oauth_tokens_refresh_token_hash_column
51
52
  # and delete the refresh_token column
52
- # t.string :refresh_token_hash, token: true
53
+ # t.string :refresh_token_hash, token: true, unique: true
53
54
  t.datetime :expires_in, null: false
54
55
  t.datetime :revoked_at
55
56
  t.string :scopes, null: false
56
57
  t.datetime :created_at, null: false, default: -> { "CURRENT_TIMESTAMP" }
58
+ # uncomment to use OIDC nonce
59
+ # t.string :nonce
57
60
  end
58
61
  end
59
62
  end