rodauth-oauth 0.10.4 → 1.0.0.pre.beta1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (65) hide show
  1. checksums.yaml +4 -4
  2. data/MIGRATION-GUIDE-v1.md +286 -0
  3. data/README.md +22 -30
  4. data/doc/release_notes/1_0_0_beta1.md +38 -0
  5. data/lib/generators/rodauth/oauth/install_generator.rb +0 -1
  6. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/authorize.html.erb +4 -6
  7. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/device_search.html.erb +1 -1
  8. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/device_verification.html.erb +2 -2
  9. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/new_oauth_application.html.erb +1 -6
  10. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/oauth_application.html.erb +0 -2
  11. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/oauth_application_oauth_grants.html.erb +41 -0
  12. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/oauth_applications.html.erb +2 -2
  13. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/oauth_grants.html.erb +37 -0
  14. data/lib/generators/rodauth/oauth/templates/db/migrate/create_rodauth_oauth.rb +18 -29
  15. data/lib/rodauth/features/oauth_application_management.rb +59 -72
  16. data/lib/rodauth/features/oauth_assertion_base.rb +19 -23
  17. data/lib/rodauth/features/oauth_authorization_code_grant.rb +35 -88
  18. data/lib/rodauth/features/oauth_authorize_base.rb +103 -20
  19. data/lib/rodauth/features/oauth_base.rb +365 -302
  20. data/lib/rodauth/features/oauth_client_credentials_grant.rb +20 -18
  21. data/lib/rodauth/features/{oauth_device_grant.rb → oauth_device_code_grant.rb} +62 -73
  22. data/lib/rodauth/features/oauth_dynamic_client_registration.rb +46 -28
  23. data/lib/rodauth/features/oauth_grant_management.rb +70 -0
  24. data/lib/rodauth/features/oauth_implicit_grant.rb +25 -24
  25. data/lib/rodauth/features/oauth_jwt.rb +52 -688
  26. data/lib/rodauth/features/oauth_jwt_base.rb +435 -0
  27. data/lib/rodauth/features/oauth_jwt_bearer_grant.rb +45 -17
  28. data/lib/rodauth/features/oauth_jwt_jwks.rb +47 -0
  29. data/lib/rodauth/features/oauth_jwt_secured_authorization_request.rb +62 -0
  30. data/lib/rodauth/features/oauth_management_base.rb +2 -0
  31. data/lib/rodauth/features/oauth_pkce.rb +22 -26
  32. data/lib/rodauth/features/oauth_resource_indicators.rb +33 -21
  33. data/lib/rodauth/features/oauth_resource_server.rb +59 -0
  34. data/lib/rodauth/features/oauth_saml_bearer_grant.rb +5 -1
  35. data/lib/rodauth/features/oauth_token_introspection.rb +76 -46
  36. data/lib/rodauth/features/oauth_token_revocation.rb +46 -33
  37. data/lib/rodauth/features/oidc.rb +188 -95
  38. data/lib/rodauth/features/oidc_dynamic_client_registration.rb +89 -53
  39. data/lib/rodauth/oauth/database_extensions.rb +8 -6
  40. data/lib/rodauth/oauth/http_extensions.rb +61 -0
  41. data/lib/rodauth/oauth/railtie.rb +20 -0
  42. data/lib/rodauth/oauth/version.rb +1 -1
  43. data/lib/rodauth/oauth.rb +29 -1
  44. data/locales/en.yml +32 -22
  45. data/locales/pt.yml +32 -22
  46. data/templates/authorize.str +19 -24
  47. data/templates/device_search.str +1 -1
  48. data/templates/device_verification.str +2 -2
  49. data/templates/jwks_field.str +1 -0
  50. data/templates/new_oauth_application.str +1 -2
  51. data/templates/oauth_application.str +2 -2
  52. data/templates/oauth_application_oauth_grants.str +54 -0
  53. data/templates/oauth_applications.str +2 -2
  54. data/templates/oauth_grants.str +52 -0
  55. metadata +20 -16
  56. data/lib/generators/rodauth/oauth/templates/app/models/oauth_token.rb +0 -4
  57. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/oauth_application_oauth_tokens.html.erb +0 -39
  58. data/lib/generators/rodauth/oauth/templates/app/views/rodauth/oauth_tokens.html.erb +0 -35
  59. data/lib/rodauth/features/oauth.rb +0 -9
  60. data/lib/rodauth/features/oauth_http_mac.rb +0 -86
  61. data/lib/rodauth/features/oauth_token_management.rb +0 -81
  62. data/lib/rodauth/oauth/refinements.rb +0 -48
  63. data/templates/jwt_public_key_field.str +0 -4
  64. data/templates/oauth_application_oauth_tokens.str +0 -52
  65. data/templates/oauth_tokens.str +0 -50
@@ -1,5 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
+ require "rodauth/oauth"
4
+
3
5
  module Rodauth
4
6
  Feature.define(:oidc_dynamic_client_registration, :OidcDynamicClientRegistration) do
5
7
  depends :oauth_dynamic_client_registration, :oidc
@@ -8,10 +10,6 @@ module Rodauth
8
10
 
9
11
  private
10
12
 
11
- def registration_metadata
12
- openid_configuration_body
13
- end
14
-
15
13
  def validate_client_registration_params
16
14
  super
17
15
 
@@ -43,11 +41,41 @@ module Rodauth
43
41
  else
44
42
  register_throw_json_response_error("invalid_client_metadata", register_invalid_application_type_message(type))
45
43
  end
46
- elsif (value = @oauth_application_params[oauth_applications_subject_type_column])
44
+ end
45
+
46
+ if (value = @oauth_application_params[oauth_applications_sector_identifier_uri_column])
47
+ uri = URI(value)
48
+
49
+ unless uri.scheme == "https" || uri.host == "localhost"
50
+ register_throw_json_response_error("invalid_redirect_uri", register_invalid_uri_message(uri))
51
+ end
52
+ end
53
+
54
+ if (value = @oauth_application_params[oauth_applications_subject_type_column])
47
55
  unless %w[pairwise public].include?(value)
48
56
  register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("subject_type"))
49
57
  end
50
- elsif (value = @oauth_application_params[oauth_applications_id_token_signed_response_alg_column])
58
+
59
+ if value == "pairwise"
60
+ sector_identifier_uri = @oauth_application_params[oauth_applications_sector_identifier_uri_column]
61
+
62
+ if sector_identifier_uri
63
+ response = http_request(sector_identifier_uri)
64
+ unless response.code.to_i == 200
65
+ register_throw_json_response_error("invalid_client_metadata",
66
+ register_invalid_param_message("sector_identifier_uri"))
67
+ end
68
+ uris = JSON.parse(response.body)
69
+
70
+ if uris != @oauth_application_params[oauth_applications_redirect_uri_column].split(" ")
71
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("sector_identifier_uri"))
72
+ end
73
+
74
+ end
75
+ end
76
+ end
77
+
78
+ if (value = @oauth_application_params[oauth_applications_id_token_signed_response_alg_column])
51
79
  if value == "none"
52
80
  # The value none MUST NOT be used as the ID Token alg value unless the Client uses only Response Types
53
81
  # that return no ID Token from the Authorization Endpoint
@@ -55,41 +83,52 @@ module Rodauth
55
83
  if response_types && response_types.include?("id_token")
56
84
  register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("id_token_signed_response_alg"))
57
85
  end
58
- elsif !oauth_jwt_algorithms_supported.include?(value)
86
+ elsif !oauth_jwt_jws_algorithms_supported.include?(value)
59
87
  register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("id_token_signed_response_alg"))
60
88
  end
61
- elsif (value = @oauth_application_params[oauth_applications_id_token_encrypted_response_alg_column])
62
- unless oauth_jwt_jwe_algorithms_supported.include?(value)
63
- register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("id_token_encrypted_response_alg"))
64
- end
65
- elsif (value = @oauth_application_params[oauth_applications_id_token_encrypted_response_enc_column])
66
- unless oauth_jwt_jwe_encryption_methods_supported.include?(value)
67
- register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("id_token_encrypted_response_enc"))
68
- end
69
- elsif (value = @oauth_application_params[oauth_applications_userinfo_signed_response_alg_column])
70
- unless oauth_jwt_algorithms_supported.include?(value)
71
- register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("userinfo_signed_response_alg"))
72
- end
73
- elsif (value = @oauth_application_params[oauth_applications_userinfo_encrypted_response_alg_column])
74
- unless oauth_jwt_jwe_algorithms_supported.include?(value)
75
- register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("userinfo_encrypted_response_alg"))
76
- end
77
- elsif (value = @oauth_application_params[oauth_applications_userinfo_encrypted_response_enc_column])
78
- unless oauth_jwt_jwe_encryption_methods_supported.include?(value)
79
- register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("userinfo_encrypted_response_enc"))
80
- end
81
- elsif (value = @oauth_application_params[oauth_applications_request_object_signing_alg_column])
82
- unless oauth_jwt_algorithms_supported.include?(value)
83
- register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("request_object_signing_alg"))
84
- end
85
- elsif (value = @oauth_application_params[oauth_applications_request_object_encryption_alg_column])
86
- unless oauth_jwt_jwe_algorithms_supported.include?(value)
87
- register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("request_object_encryption_alg"))
88
- end
89
- elsif (value = @oauth_application_params[oauth_applications_request_object_encryption_enc_column])
90
- unless oauth_jwt_jwe_encryption_methods_supported.include?(value)
91
- register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("request_object_encryption_enc"))
92
- end
89
+ end
90
+
91
+ if (value = @oauth_application_params[oauth_applications_id_token_encrypted_response_alg_column]) &&
92
+ !oauth_jwt_jwe_algorithms_supported.include?(value)
93
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("id_token_encrypted_response_alg"))
94
+ end
95
+
96
+ if (value = @oauth_application_params[oauth_applications_id_token_encrypted_response_enc_column]) &&
97
+ !oauth_jwt_jwe_encryption_methods_supported.include?(value)
98
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("id_token_encrypted_response_enc"))
99
+ end
100
+
101
+ if (value = @oauth_application_params[oauth_applications_userinfo_signed_response_alg_column]) &&
102
+ !oauth_jwt_jws_algorithms_supported.include?(value)
103
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("userinfo_signed_response_alg"))
104
+ end
105
+
106
+ if (value = @oauth_application_params[oauth_applications_userinfo_encrypted_response_alg_column]) &&
107
+ !oauth_jwt_jwe_algorithms_supported.include?(value)
108
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("userinfo_encrypted_response_alg"))
109
+ end
110
+
111
+ if (value = @oauth_application_params[oauth_applications_userinfo_encrypted_response_enc_column]) &&
112
+ !oauth_jwt_jwe_encryption_methods_supported.include?(value)
113
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("userinfo_encrypted_response_enc"))
114
+ end
115
+
116
+ if defined?(oauth_applications_request_object_signing_alg_column) &&
117
+ (value = @oauth_application_params[oauth_applications_request_object_signing_alg_column]) &&
118
+ !oauth_jwt_jws_algorithms_supported.include?(value)
119
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("request_object_signing_alg"))
120
+ end
121
+
122
+ if defined?(oauth_applications_request_object_encryption_alg_column) &&
123
+ (value = @oauth_application_params[oauth_applications_request_object_encryption_alg_column]) &&
124
+ !oauth_jwt_jwe_algorithms_supported.include?(value)
125
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("request_object_encryption_alg"))
126
+ end
127
+
128
+ if defined?(oauth_applications_request_object_encryption_enc_column) &&
129
+ (value = @oauth_application_params[oauth_applications_request_object_encryption_enc_column]) &&
130
+ !oauth_jwt_jwe_encryption_methods_supported.include?(value)
131
+ register_throw_json_response_error("invalid_client_metadata", register_invalid_param_message("request_object_encryption_enc"))
93
132
  end
94
133
  end
95
134
 
@@ -114,27 +153,24 @@ module Rodauth
114
153
  return_params["application_type"] = "web"
115
154
  "web"
116
155
  end
117
- create_params[oauth_applications_id_token_signed_response_alg_column] ||= begin
118
- return_params["id_token_signed_response_alg"] = oauth_jwt_algorithm
119
- oauth_jwt_algorithm
120
- end
156
+ create_params[oauth_applications_id_token_signed_response_alg_column] ||= return_params["id_token_signed_response_alg"] =
157
+ oauth_jwt_keys.keys.first
158
+
121
159
  if create_params.key?(oauth_applications_id_token_encrypted_response_alg_column)
122
- create_params[oauth_applications_id_token_encrypted_response_enc_column] ||= begin
123
- return_params["id_token_encrypted_response_enc"] = "A128CBC-HS256"
160
+ create_params[oauth_applications_id_token_encrypted_response_enc_column] ||= return_params["id_token_encrypted_response_enc"] =
124
161
  "A128CBC-HS256"
125
- end
162
+
126
163
  end
127
164
  if create_params.key?(oauth_applications_userinfo_encrypted_response_alg_column)
128
- create_params[oauth_applications_userinfo_encrypted_response_enc_column] ||= begin
129
- return_params["userinfo_encrypted_response_enc"] = "A128CBC-HS256"
165
+ create_params[oauth_applications_userinfo_encrypted_response_enc_column] ||= return_params["userinfo_encrypted_response_enc"] =
130
166
  "A128CBC-HS256"
131
- end
167
+
132
168
  end
133
- if create_params.key?(oauth_applications_request_object_encryption_alg_column)
134
- create_params[oauth_applications_request_object_encryption_enc_column] ||= begin
135
- return_params["request_object_encryption_enc"] = "A128CBC-HS256"
169
+ if defined?(oauth_applications_request_object_encryption_alg_column) &&
170
+ create_params.key?(oauth_applications_request_object_encryption_alg_column)
171
+ create_params[oauth_applications_request_object_encryption_enc_column] ||= return_params["request_object_encryption_enc"] =
136
172
  "A128CBC-HS256"
137
- end
173
+
138
174
  end
139
175
 
140
176
  super(return_params)
@@ -30,13 +30,14 @@ module Rodauth
30
30
  end
31
31
 
32
32
  if dataset.respond_to?(:supports_insert_conflict?) && dataset.supports_insert_conflict?
33
- def __insert_or_update_and_return__(dataset, pkey, unique_columns, params, conds = nil, exclude_on_update = nil)
34
- to_update = params.keys - unique_columns
35
- to_update -= exclude_on_update if exclude_on_update
33
+ def __insert_or_update_and_return__(dataset, pkey, unique_columns, params, conds = nil, to_update_extra = nil)
34
+ to_update = Hash[(params.keys - unique_columns).map { |attribute| [attribute, Sequel[:excluded][attribute]] }]
35
+
36
+ to_update.merge!(to_update_extra) if to_update_extra
36
37
 
37
38
  dataset = dataset.insert_conflict(
38
39
  target: unique_columns,
39
- update: Hash[ to_update.map { |attribute| [attribute, Sequel[:excluded][attribute]] } ],
40
+ update: to_update,
40
41
  update_where: conds
41
42
  )
42
43
 
@@ -51,7 +52,7 @@ module Rodauth
51
52
  ) || dataset.where(params).first
52
53
  end
53
54
  else
54
- def __insert_or_update_and_return__(dataset, pkey, unique_columns, params, conds = nil, exclude_on_update = nil)
55
+ def __insert_or_update_and_return__(dataset, pkey, unique_columns, params, conds = nil, to_update_extra = nil)
55
56
  find_params, update_params = params.partition { |key, _| unique_columns.include?(key) }.map { |h| Hash[h] }
56
57
 
57
58
  dataset_where = dataset.where(find_params)
@@ -67,7 +68,8 @@ module Rodauth
67
68
  end
68
69
 
69
70
  if record
70
- update_params.reject! { |k, _v| exclude_on_update.include?(k) } if exclude_on_update
71
+ update_params.merge!(to_update_extra) if to_update_extra
72
+
71
73
  __update_and_return__(dataset_where, update_params)
72
74
  else
73
75
  __insert_and_return__(dataset, pkey, params)
@@ -0,0 +1,61 @@
1
+ # frozen_string_literal: true
2
+
3
+ require "uri"
4
+ require "net/http"
5
+ require "rodauth/oauth/ttl_store"
6
+
7
+ module Rodauth
8
+ module OAuth
9
+ module HTTPExtensions
10
+ REQUEST_CACHE = OAuth::TtlStore.new
11
+
12
+ private
13
+
14
+ def http_request(uri, form_data = nil)
15
+ uri = URI(uri)
16
+
17
+ http = Net::HTTP.new(uri.host, uri.port)
18
+ http.use_ssl = uri.scheme == "https"
19
+
20
+ if form_data
21
+ request = Net::HTTP::Post.new(uri.request_uri)
22
+ request["content-type"] = "application/x-www-form-urlencoded"
23
+ request.set_form_data(form_data)
24
+ else
25
+ request = Net::HTTP::Get.new(uri.request_uri)
26
+ end
27
+ request["accept"] = json_response_content_type
28
+
29
+ yield request if block_given?
30
+
31
+ response = http.request(request)
32
+ authorization_required unless response.code.to_i == 200
33
+ response
34
+ end
35
+
36
+ def http_request_with_cache(uri, *args)
37
+ uri = URI(uri)
38
+
39
+ response = http_request_cache[uri]
40
+
41
+ return response if response
42
+
43
+ http_request_cache.set(uri) do
44
+ response = http_request(uri, *args)
45
+ ttl = if response.key?("cache-control")
46
+ cache_control = response["cache-control"]
47
+ cache_control[/max-age=(\d+)/, 1].to_i
48
+ elsif response.key?("expires")
49
+ Time.parse(response["expires"]).to_i - Time.now.to_i
50
+ end
51
+
52
+ [JSON.parse(response.body, symbolize_names: true), ttl]
53
+ end
54
+ end
55
+
56
+ def http_request_cache
57
+ REQUEST_CACHE
58
+ end
59
+ end
60
+ end
61
+ end
@@ -2,7 +2,27 @@
2
2
 
3
3
  module Rodauth
4
4
  module OAuth
5
+ module ControllerMethods
6
+ def self.included(controller)
7
+ # ActionController::API doesn't have helper methods
8
+ controller.helper_method :current_oauth_account, :current_oauth_application if controller.respond_to?(:helper_method)
9
+ end
10
+
11
+ def current_oauth_account(name = nil)
12
+ rodauth(name).current_oauth_account
13
+ end
14
+
15
+ def current_oauth_application(name = nil)
16
+ rodauth(name).current_oauth_application
17
+ end
18
+ end
19
+
5
20
  class Railtie < ::Rails::Railtie
21
+ initializer "rodauth.controller" do
22
+ ActiveSupport.on_load(:action_controller) do
23
+ include ControllerMethods
24
+ end
25
+ end
6
26
  end
7
27
  end
8
28
  end
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Rodauth
4
4
  module OAuth
5
- VERSION = "0.10.4"
5
+ VERSION = "1.0.0-beta1"
6
6
  end
7
7
  end
data/lib/rodauth/oauth.rb CHANGED
@@ -1,7 +1,35 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  require "rodauth"
4
-
5
4
  require "rodauth/oauth/version"
6
5
 
6
+ module Rodauth
7
+ module OAuth
8
+ module FeatureExtensions
9
+ def auth_server_route(*args, &blk)
10
+ routes = route(*args, &blk)
11
+
12
+ handle_meth = routes.last
13
+
14
+ define_method(:"#{handle_meth}_for_auth_server") do
15
+ next unless is_authorization_server?
16
+
17
+ send(:"#{handle_meth}_not_for_auth_server")
18
+ end
19
+
20
+ alias_method :"#{handle_meth}_not_for_auth_server", handle_meth
21
+ alias_method handle_meth, :"#{handle_meth}_for_auth_server"
22
+ end
23
+
24
+ # override
25
+ def translatable_method(meth, value)
26
+ define_method(meth) { |*args| translate(meth, value, *args) }
27
+ auth_value_methods(meth)
28
+ end
29
+ end
30
+ end
31
+
32
+ Feature.prepend OAuth::FeatureExtensions
33
+ end
34
+
7
35
  require "rodauth/oauth/railtie" if defined?(Rails)
data/locales/en.yml CHANGED
@@ -3,21 +3,29 @@ en:
3
3
  require_authorization_error_flash: "Please authorize to continue"
4
4
  create_oauth_application_error_flash: "There was an error registering your oauth application"
5
5
  create_oauth_application_notice_flash: "Your oauth application has been registered"
6
- revoke_unauthorized_account_error_flash: "You are not authorized to revoke this token"
7
- revoke_oauth_token_notice_flash: "The oauth token has been revoked"
6
+ revoke_unauthorized_account_error_flash: "You are not authorized to revoke this grant"
7
+ revoke_oauth_grant_notice_flash: "The oauth grant has been revoked"
8
8
  device_verification_notice_flash: "The device is verified"
9
9
  user_code_not_found_error_flash: "No device to authorize with the given user code"
10
10
  authorize_page_title: "Authorize"
11
+ authorize_page_lead: "The application %{name} would like to access your data."
12
+ oauth_cancel_button: "Cancel"
11
13
  oauth_applications_page_title: "Oauth Applications"
12
14
  oauth_application_page_title: "Oauth Application"
13
15
  new_oauth_application_page_title: "New Oauth Application"
14
- oauth_application_oauth_tokens_page_title: "Application Oauth Tokens"
15
- oauth_tokens_page_title: "My Oauth Tokens"
16
+ oauth_application_oauth_grants_page_title: "Application Oauth Grants"
17
+ oauth_grants_page_title: "My Oauth Grants"
16
18
  device_verification_page_title: "Device Verification"
17
19
  device_search_page_title: "Device Search"
18
20
  oauth_management_pagination_previous_button: "Previous"
19
21
  oauth_management_pagination_next_button: "Next"
20
- oauth_tokens_scopes_label: "Scopes"
22
+ oauth_grants_type_label: "Grant Type"
23
+ oauth_grants_scopes_label: "Scopes"
24
+ oauth_grants_token_label: "Token"
25
+ oauth_grants_refresh_token_label: "Refresh Token"
26
+ oauth_grants_expires_in_label: "Expires In"
27
+ oauth_grants_revoked_at_label: "Revoked at"
28
+ oauth_no_grants_text: "No oauth grants yet!"
21
29
  oauth_applications_name_label: "Name"
22
30
  oauth_applications_description_label: "Description"
23
31
  oauth_applications_scopes_label: "Default scopes"
@@ -28,30 +36,32 @@ en:
28
36
  oauth_applications_redirect_uri_label: "Redirect URL"
29
37
  oauth_applications_client_secret_label: "Client Secret"
30
38
  oauth_applications_client_id_label: "Client ID"
39
+ oauth_no_applications_text: "No oauth applications yet!"
31
40
  oauth_grant_user_code_label: "User code"
32
41
  oauth_grant_user_jws_jwk_label: "JSON Web Keys"
33
42
  oauth_grant_user_jwt_public_key_label: "Public key"
34
43
  oauth_application_button: "Register"
35
44
  oauth_authorize_button: "Authorize"
36
- oauth_token_revoke_button: "Revoke"
45
+ oauth_grant_revoke_button: "Revoke"
37
46
  oauth_authorize_post_button: "Back to Client Application"
47
+ oauth_device_verification_page_lead: "The device with user code %{user_code} would like to access your data."
38
48
  oauth_device_verification_button: "Verify"
49
+ oauth_device_search_page_lead: "Insert the user code from the device you'd like to authorize."
39
50
  oauth_device_search_button: "Search"
40
- invalid_client_message: "Client authentication failed"
41
- invalid_grant_type_message: "Invalid grant type"
42
- invalid_grant_message: "Invalid grant"
43
- invalid_scope_message: "Invalid scope"
51
+ oauth_invalid_client_message: "Client authentication failed"
52
+ oauth_invalid_grant_type_message: "Invalid grant type"
53
+ oauth_invalid_grant_message: "Invalid grant"
54
+ oauth_invalid_scope_message: "Invalid scope"
44
55
  invalid_url_message: "Invalid URL"
45
- unsupported_token_type_message: "Invalid token type hint"
46
- unique_error_message: "is already in use"
56
+ oauth_unsupported_token_type_message: "Invalid token type hint"
47
57
  null_error_message: "is not filled"
48
- already_in_use_message: "error generating unique token"
49
- expired_token_message: "the device code has expired"
50
- access_denied_message: "the authorization request has been denied"
51
- authorization_pending_message: "the authorization request is still pending"
52
- slow_down_message: "authorization request is still pending but poll interval should be increased"
53
- code_challenge_required_message: "code challenge required"
54
- unsupported_transform_algorithm_message: "transform algorithm not supported"
55
- request_uri_not_supported_message: "request uri is unsupported"
56
- invalid_request_object_message: "request object is invalid"
57
- invalid_scope_message: "The Access Token expired"
58
+ oauth_already_in_use_message: "error generating unique token"
59
+ oauth_expired_token_message: "the device code has expired"
60
+ oauth_access_denied_message: "the authorization request has been denied"
61
+ oauth_authorization_pending_message: "the authorization request is still pending"
62
+ oauth_slow_down_message: "authorization request is still pending but poll interval should be increased"
63
+ oauth_code_challenge_required_message: "code challenge required"
64
+ oauth_unsupported_transform_algorithm_message: "transform algorithm not supported"
65
+ oauth_request_uri_not_supported_message: "request uri is unsupported"
66
+ oauth_invalid_request_object_message: "request object is invalid"
67
+ oauth_invalid_scope_message: "The Access Token expired"
data/locales/pt.yml CHANGED
@@ -3,21 +3,29 @@ pt:
3
3
  require_authorization_error_flash: "Autorize para continuar"
4
4
  create_oauth_application_error_flash: "Aconteceu um erro ao registar o aplicativo oauth"
5
5
  create_oauth_application_notice_flash: "O seu aplicativo oauth foi registado com sucesso"
6
- revoke_unauthorized_account_error_flash: "Não está autorizado a revogar este token"
7
- revoke_oauth_token_notice_flash: "O token oauth foi revogado com sucesso"
6
+ revoke_unauthorized_account_error_flash: "Não está autorizado a revogar esta concessão"
7
+ revoke_oauth_grant_notice_flash: "O token oauth foi revogado com sucesso"
8
8
  device_verification_notice_flash: "O dispositivo foi verificado com sucesso"
9
9
  user_code_not_found_error_flash: "Não existe nenhum dispositivo a ser autorizado com o código de usuário inserido"
10
10
  authorize_page_title: "Autorizar"
11
+ authorize_page_lead: "O aplicativo %{name} gostaria de aceder aos seus dados."
12
+ oauth_cancel_button: "Cancelar"
11
13
  oauth_applications_page_title: "Aplicativos OAuth"
12
14
  oauth_application_page_title: "Aplicativo Oauth"
13
15
  new_oauth_application_page_title: "Novo Aplicativo Oauth"
14
- oauth_application_oauth_tokens_page_title: "Tokens Oauth do Aplicativo"
15
- oauth_tokens_page_title: "Os meus Tokens Oauth"
16
+ oauth_application_oauth_grants_page_title: "Concessões Oauth do Aplicativo"
17
+ oauth_grants_page_title: "As minhas concessões Oauth"
16
18
  device_verification_page_title: "Verificação de dispositivo"
17
19
  device_search_page_title: "Pesquisa de dispositivo"
18
20
  oauth_management_pagination_previous_button: "Anterior"
19
21
  oauth_management_pagination_next_button: "Próxima"
20
- oauth_tokens_scopes_label: "Escopos"
22
+ oauth_grants_type_label: "Tipo de concessão"
23
+ oauth_grants_scopes_label: "Escopos"
24
+ oauth_grants_token_label: "Token"
25
+ oauth_grants_refresh_token_label: "Refresh Token"
26
+ oauth_grants_expires_in_label: "Expira em"
27
+ oauth_grants_revoked_at_label: "Revogado a"
28
+ oauth_no_grants_text: "Nenhuma concessão OAuth ainda!"
21
29
  oauth_applications_name_label: "Nome"
22
30
  oauth_applications_description_label: "Descrição"
23
31
  oauth_applications_scopes_label: "Escopos prédefinidos"
@@ -28,30 +36,32 @@ pt:
28
36
  oauth_applications_redirect_uri_label: "URL para redireccionamento"
29
37
  oauth_applications_client_secret_label: "Segredo de cliente"
30
38
  oauth_applications_client_id_label: "ID do cliente"
39
+ oauth_no_applications_text: "Nenhum aplicativo OAuth ainda!"
31
40
  oauth_grant_user_code_label: "Código do usuário"
32
41
  oauth_grant_user_jws_jwk_label: "Chaves JSON Web"
33
42
  oauth_grant_user_jwt_public_key_label: "Chave pública"
34
43
  oauth_application_button: "Registar"
35
44
  oauth_authorize_button: "Autorizar"
36
- oauth_token_revoke_button: "Revogar"
45
+ oauth_grant_revoke_button: "Revogar"
37
46
  oauth_authorize_post_button: "Voltar para o aplicativo cliente"
47
+ oauth_device_verification_page_lead: "O dispositivo com o código de usuário %{user_code} gostaria de aceder aos seus dados."
38
48
  oauth_device_verification_button: "Verificar"
49
+ oauth_device_search_page_lead: "Introduza o código de usuário do dispositivo que gostaria de autorizar."
39
50
  oauth_device_search_button: "Pesquisar"
40
- invalid_client_message: "A autenticação do cliente falhou"
41
- invalid_grant_type_message: "Tipo de atribuição inválida"
42
- invalid_grant_message: "Atribuição inválida"
43
- invalid_scope_message: "Escopo inválido"
51
+ oauth_invalid_client_message: "A autenticação do cliente falhou"
52
+ oauth_invalid_grant_type_message: "Tipo de atribuição inválida"
53
+ oauth_invalid_grant_message: "Atribuição inválida"
54
+ oauth_invalid_scope_message: "Escopo inválido"
44
55
  invalid_url_message: "URL inválido"
45
- unsupported_token_type_message: "Sugestão de tipo de token inválida"
46
- unique_error_message: "já está sendo utilizado"
56
+ oauth_unsupported_token_type_message: "Sugestão de tipo de token inválida"
47
57
  null_error_message: "não está preenchido"
48
- already_in_use_message: "erro ao gerar token único"
49
- expired_token_message: "o código de dispositivo expirou"
50
- access_denied_message: "o pedido de autorização foi negado"
51
- authorization_pending_message: "o pedido de autorização ainda está pendente"
52
- slow_down_message: "o pedido de autorização ainda está pendente mas o intervalo de actualização deve ser aumentado"
53
- code_challenge_required_message: "código de negociação necessário"
54
- unsupported_transform_algorithm_message: "algoritmo de transformação não suportado"
55
- request_uri_not_supported_message: "request_uri não é suportado"
56
- invalid_request_object_message: "request_object é inválido"
57
- invalid_scope_message: "O Token de acesso expirou"
58
+ oauth_already_in_use_message: "erro ao gerar token único"
59
+ oauth_expired_token_message: "o código de dispositivo expirou"
60
+ oauth_access_denied_message: "o pedido de autorização foi negado"
61
+ oauth_authorization_pending_message: "o pedido de autorização ainda está pendente"
62
+ oauth_slow_down_message: "o pedido de autorização ainda está pendente mas o intervalo de actualização deve ser aumentado"
63
+ oauth_code_challenge_required_message: "código de negociação necessário"
64
+ oauth_unsupported_transform_algorithm_message: "algoritmo de transformação não suportado"
65
+ oauth_request_uri_not_supported_message: "request_uri não é suportado"
66
+ oauth_invalid_request_object_message: "request_object é inválido"
67
+ oauth_invalid_scope_message: "O Token de acesso expirou"
@@ -8,10 +8,14 @@
8
8
  end
9
9
  }
10
10
  <p class="lead">
11
- The application
12
- <a target="_blank" href="#{h(rodauth.oauth_application[rodauth.oauth_applications_homepage_url_column])}">
13
- #{h(rodauth.oauth_application[rodauth.oauth_applications_name_column])}
14
- </a> would like to access your data.
11
+ #{
12
+ rodauth.authorize_page_lead(name: <<-LINK
13
+ <a target="_blank" href="#{h(rodauth.oauth_application[rodauth.oauth_applications_homepage_url_column])}">
14
+ #{h(rodauth.oauth_application[rodauth.oauth_applications_name_column])}
15
+ </a>
16
+ LINK
17
+ )
18
+ }
15
19
  </p>
16
20
  <div class="list-group">
17
21
  #{
@@ -52,31 +56,20 @@
52
56
  }
53
57
 
54
58
  <div class="form-group">
55
- <h1 class="display-6">#{rodauth.oauth_tokens_scopes_label}</h1>
59
+ <h1 class="display-6">#{rodauth.oauth_grants_scopes_label}</h1>
56
60
 
57
61
  #{
58
- rodauth.scopes.map do |scope|
59
- if scope == rodauth.oauth_application_default_scope
60
- <<-HTML
61
- <div class="form-check">
62
- <input id="#{scope}" class="form-check-input" type="checkbox" name="scope[]" value="#{h(scope)}" checked disabled>
63
- <label class="form-check-label" for="#{scope}">#{h(scope)}</label>
64
- <input type="hidden" name="scope[]" value="#{h(scope)}">
65
- </div>
66
- HTML
67
- else
68
- <<-HTML
69
- <div class="form-check">
70
- <input id="#{scope}" class="form-check-input" type="checkbox" name="scope[]" value="#{h(scope)}">
71
- <label class="form-check-label" for="#{scope}">#{h(scope)}</label>
72
- </div>
73
- HTML
74
- end
62
+ rodauth.authorize_scopes.map do |scope|
63
+ <<-HTML
64
+ <div class="form-check">
65
+ <input id="#{scope}" class="form-check-input" type="checkbox" name="scope[]" value="#{h(scope)}">
66
+ <label class="form-check-label" for="#{scope}">#{h(scope)}</label>
67
+ </div>
68
+ HTML
75
69
  end.join
76
70
  }
77
71
 
78
72
  <input type="hidden" name="client_id" value="#{rodauth.param("client_id")}"/>
79
-
80
73
  #{"<input type=\"hidden\" name=\"access_type\" value=\"#{rodauth.param("access_type")}\"/>" if rodauth.param_or_nil("access_type")}
81
74
  #{"<input type=\"hidden\" name=\"response_type\" value=\"#{rodauth.param("response_type")}\"/>" if rodauth.param_or_nil("response_type")}
82
75
  #{"<input type=\"hidden\" name=\"response_mode\" value=\"#{rodauth.param("response_mode")}\"/>" if rodauth.param_or_nil("response_mode")}
@@ -98,6 +91,8 @@
98
91
  </div>
99
92
  <p class="text-center">
100
93
  <input type="submit" class="btn btn-outline-primary" value="#{h(rodauth.oauth_authorize_button)}"/>
101
- <a href="#{rodauth.redirect_uri}?error=access_denied&error_description=The+resource+owner+or+authorization+server+denied+the+request#{ "&state=#{rodauth.param("state")}" if rodauth.param_or_nil("state")}" class="btn btn-outline-danger">#{rodauth.oauth_cancel_button}</a>
94
+ <a href="#{rodauth.redirect_uri}?error=access_denied&error_description=The+resource+owner+or+authorization+server+denied+the+request#{ "&state=#{rodauth.param("state")}" if rodauth.param_or_nil("state")}" class="btn btn-outline-danger">
95
+ #{rodauth.oauth_cancel_button}
96
+ </a>
102
97
  </p>
103
98
  </form>
@@ -1,5 +1,5 @@
1
1
  <form method="get" action="#{rodauth.device_path}" class="form-horizontal" role="form" id="device-search-form">
2
- <p class="lead">Insert the user code from the device you'd like to authorize.</p>
2
+ <p class="lead">#{rodauth.oauth_device_search_page_lead}</p>
3
3
 
4
4
  <div class="form-group">
5
5
  <label for="user_code">#{rodauth.oauth_grant_user_code_label}</label>
@@ -1,9 +1,9 @@
1
1
  <form method="post" action="#{rodauth.device_path}" class="form-horizontal" role="form" id="device-verification-form">
2
2
  #{csrf_tag(rodauth.device_path) if respond_to?(:csrf_tag)}
3
- <p class="lead">The device with user code #{@oauth_grant[rodauth.oauth_grants_user_code_column]} would like to access your data.</p>
3
+ <p class="lead">#{rodauth.oauth_device_verification_page_lead(user_code: @oauth_grant[rodauth.oauth_grants_user_code_column])}</p>
4
4
 
5
5
  <div class="form-group">
6
- <h1 class="display-6">#{rodauth.oauth_tokens_scopes_label}</h1>
6
+ <h1 class="display-6">#{rodauth.oauth_grants_scopes_label}</h1>
7
7
 
8
8
  <ul class="list-group">
9
9
  #{
@@ -2,3 +2,4 @@
2
2
  <label for="name">#{rodauth.oauth_applications_jwks_label}#{rodauth.input_field_label_suffix}</label>
3
3
  <textarea id="jwks" class="form-control" name="#{rodauth.oauth_application_jwks_param}" rows="3"></textarea>
4
4
  </div>
5
+ #{rodauth.input_field_string(rodauth.oauth_application_jwks_uri_param, "jwks-uri", :type=>"text")}