rodauth-oauth 1.1.0 → 1.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/README.md +11 -8
- data/doc/release_notes/1_1_0.md +1 -1
- data/doc/release_notes/1_2_0.md +36 -0
- data/doc/release_notes/1_3_0.md +38 -0
- data/lib/generators/rodauth/oauth/templates/app/views/rodauth/authorize.html.erb +3 -0
- data/lib/generators/rodauth/oauth/templates/db/migrate/create_rodauth_oauth.rb +32 -9
- data/lib/rodauth/features/oauth_authorization_code_grant.rb +55 -33
- data/lib/rodauth/features/oauth_authorize_base.rb +25 -3
- data/lib/rodauth/features/oauth_base.rb +16 -16
- data/lib/rodauth/features/oauth_device_code_grant.rb +1 -2
- data/lib/rodauth/features/oauth_dynamic_client_registration.rb +182 -29
- data/lib/rodauth/features/oauth_implicit_grant.rb +23 -5
- data/lib/rodauth/features/oauth_jwt.rb +2 -0
- data/lib/rodauth/features/oauth_jwt_base.rb +52 -11
- data/lib/rodauth/features/oauth_jwt_secured_authorization_request.rb +30 -22
- data/lib/rodauth/features/oauth_jwt_secured_authorization_response_mode.rb +126 -0
- data/lib/rodauth/features/oauth_management_base.rb +1 -3
- data/lib/rodauth/features/oauth_pushed_authorization_request.rb +135 -0
- data/lib/rodauth/features/oauth_tls_client_auth.rb +170 -0
- data/lib/rodauth/features/oidc.rb +97 -59
- data/lib/rodauth/features/oidc_dynamic_client_registration.rb +52 -2
- data/lib/rodauth/features/oidc_rp_initiated_logout.rb +3 -4
- data/lib/rodauth/features/oidc_self_issued.rb +73 -0
- data/lib/rodauth/oauth/version.rb +1 -1
- data/templates/authorize.str +1 -0
- metadata +10 -2
@@ -36,10 +36,9 @@ module Rodauth
|
|
36
36
|
|
37
37
|
oauth_application = db[oauth_applications_table].where(oauth_applications_client_id_column => claims["aud"]).first
|
38
38
|
oauth_grant = db[oauth_grants_table]
|
39
|
-
.where(
|
40
|
-
|
41
|
-
|
42
|
-
).first
|
39
|
+
.where(resource_owner_params)
|
40
|
+
.where(oauth_grants_oauth_application_id_column => oauth_application[oauth_applications_id_column])
|
41
|
+
.first
|
43
42
|
|
44
43
|
# check whether ID token belongs to currently logged-in user
|
45
44
|
redirect_logout_with_error(oauth_invalid_client_message) unless oauth_grant && claims["sub"] == jwt_subject(oauth_grant,
|
@@ -0,0 +1,73 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require "rodauth/oauth"
|
4
|
+
|
5
|
+
module Rodauth
|
6
|
+
Feature.define(:oidc_self_issued, :OidcSelfIssued) do
|
7
|
+
depends :oidc, :oidc_dynamic_client_registration
|
8
|
+
|
9
|
+
auth_value_method :oauth_application_scopes, %w[openid profile email address phone]
|
10
|
+
auth_value_method :oauth_jwt_jws_algorithms_supported, %w[RS256]
|
11
|
+
|
12
|
+
SELF_ISSUED_DEFAULT_APPLICATION_PARAMS = {
|
13
|
+
"scope" => "openid profile email address phone",
|
14
|
+
"response_types" => ["id_token"],
|
15
|
+
"subject_type" => "pairwise",
|
16
|
+
"id_token_signed_response_alg" => "RS256",
|
17
|
+
"request_object_signing_alg" => "RS256",
|
18
|
+
"grant_types" => %w[implicit]
|
19
|
+
}.freeze
|
20
|
+
|
21
|
+
def oauth_application
|
22
|
+
return @oauth_application if defined?(@oauth_application)
|
23
|
+
|
24
|
+
return super unless (registration = param_or_nil("registration"))
|
25
|
+
|
26
|
+
# self-issued!
|
27
|
+
redirect_uri = param_or_nil("client_id")
|
28
|
+
|
29
|
+
registration_params = JSON.parse(registration)
|
30
|
+
|
31
|
+
registration_params = SELF_ISSUED_DEFAULT_APPLICATION_PARAMS.merge(registration_params)
|
32
|
+
|
33
|
+
client_params = validate_client_registration_params(registration_params)
|
34
|
+
|
35
|
+
request.params["redirect_uri"] = client_params[oauth_applications_client_id_column] = redirect_uri
|
36
|
+
client_params[oauth_applications_redirect_uri_column] ||= redirect_uri
|
37
|
+
|
38
|
+
@oauth_application = client_params
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
|
43
|
+
def oauth_response_types_supported
|
44
|
+
%w[id_token]
|
45
|
+
end
|
46
|
+
|
47
|
+
def request_object_signing_alg_values_supported
|
48
|
+
%w[none RS256]
|
49
|
+
end
|
50
|
+
|
51
|
+
def id_token_claims(oauth_grant, signing_algorithm)
|
52
|
+
claims = super
|
53
|
+
|
54
|
+
return claims unless claims[:client_id] == oauth_grant[oauth_grants_redirect_uri_column]
|
55
|
+
|
56
|
+
# https://openid.net/specs/openid-connect-core-1_0.html#SelfIssued - 7.4
|
57
|
+
|
58
|
+
pub_key = oauth_jwt_public_keys[signing_algorithm]
|
59
|
+
pub_key = pub_key.first if pub_key.is_a?(Array)
|
60
|
+
claims[:sub_jwk] = sub_jwk = jwk_export(pub_key)
|
61
|
+
|
62
|
+
claims[:iss] = "https://self-issued.me"
|
63
|
+
|
64
|
+
claims[:aud] = oauth_grant[oauth_grants_redirect_uri_column]
|
65
|
+
|
66
|
+
jwk_thumbprint = jwk_thumbprint(sub_jwk)
|
67
|
+
|
68
|
+
claims[:sub] = Base64.urlsafe_encode64(jwk_thumbprint, padding: false)
|
69
|
+
|
70
|
+
claims
|
71
|
+
end
|
72
|
+
end
|
73
|
+
end
|
data/templates/authorize.str
CHANGED
@@ -88,6 +88,7 @@
|
|
88
88
|
#{"<input type=\"hidden\" name=\"claims_locales\" value=\"#{rodauth.param("claims_locales")}\"/>" if rodauth.features.include?(:oidc) && rodauth.param_or_nil("claims_locales")}
|
89
89
|
#{"<input type=\"hidden\" name=\"claims\" value=\"#{h(rodauth.param("claims"))}\"/>" if rodauth.features.include?(:oidc) && rodauth.param_or_nil("claims")}
|
90
90
|
#{"<input type=\"hidden\" name=\"acr_values\" value=\"#{rodauth.param("acr_values")}\"/>" if rodauth.features.include?(:oidc) && rodauth.param_or_nil("acr_values")}
|
91
|
+
#{"<input type=\"hidden\" name=\"registration\" value=\"#{h(rodauth.param("registration"))}\"/>" if rodauth.features.include?(:oidc_self_issued) && rodauth.param_or_nil("registration")}
|
91
92
|
#{
|
92
93
|
if rodauth.features.include?(:oauth_resource_indicators) && rodauth.resource_indicators
|
93
94
|
rodauth.resource_indicators.map do |resource|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rodauth-oauth
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Tiago Cardoso
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2023-01
|
11
|
+
date: 2023-04-01 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rodauth
|
@@ -68,6 +68,8 @@ extra_rdoc_files:
|
|
68
68
|
- doc/release_notes/0_9_3.md
|
69
69
|
- doc/release_notes/1_0_0.md
|
70
70
|
- doc/release_notes/1_1_0.md
|
71
|
+
- doc/release_notes/1_2_0.md
|
72
|
+
- doc/release_notes/1_3_0.md
|
71
73
|
files:
|
72
74
|
- CHANGELOG.md
|
73
75
|
- LICENSE.txt
|
@@ -107,6 +109,8 @@ files:
|
|
107
109
|
- doc/release_notes/0_9_3.md
|
108
110
|
- doc/release_notes/1_0_0.md
|
109
111
|
- doc/release_notes/1_1_0.md
|
112
|
+
- doc/release_notes/1_2_0.md
|
113
|
+
- doc/release_notes/1_3_0.md
|
110
114
|
- lib/generators/rodauth/oauth/install_generator.rb
|
111
115
|
- lib/generators/rodauth/oauth/templates/app/models/oauth_application.rb
|
112
116
|
- lib/generators/rodauth/oauth/templates/app/models/oauth_grant.rb
|
@@ -136,16 +140,20 @@ files:
|
|
136
140
|
- lib/rodauth/features/oauth_jwt_bearer_grant.rb
|
137
141
|
- lib/rodauth/features/oauth_jwt_jwks.rb
|
138
142
|
- lib/rodauth/features/oauth_jwt_secured_authorization_request.rb
|
143
|
+
- lib/rodauth/features/oauth_jwt_secured_authorization_response_mode.rb
|
139
144
|
- lib/rodauth/features/oauth_management_base.rb
|
140
145
|
- lib/rodauth/features/oauth_pkce.rb
|
146
|
+
- lib/rodauth/features/oauth_pushed_authorization_request.rb
|
141
147
|
- lib/rodauth/features/oauth_resource_indicators.rb
|
142
148
|
- lib/rodauth/features/oauth_resource_server.rb
|
143
149
|
- lib/rodauth/features/oauth_saml_bearer_grant.rb
|
150
|
+
- lib/rodauth/features/oauth_tls_client_auth.rb
|
144
151
|
- lib/rodauth/features/oauth_token_introspection.rb
|
145
152
|
- lib/rodauth/features/oauth_token_revocation.rb
|
146
153
|
- lib/rodauth/features/oidc.rb
|
147
154
|
- lib/rodauth/features/oidc_dynamic_client_registration.rb
|
148
155
|
- lib/rodauth/features/oidc_rp_initiated_logout.rb
|
156
|
+
- lib/rodauth/features/oidc_self_issued.rb
|
149
157
|
- lib/rodauth/oauth.rb
|
150
158
|
- lib/rodauth/oauth/database_extensions.rb
|
151
159
|
- lib/rodauth/oauth/http_extensions.rb
|