standard_id 0.42.0 → 0.43.1
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/CHANGELOG.md +70 -0
- data/README.md +69 -7
- data/app/controllers/concerns/standard_id/rate_limit_handling.rb +5 -19
- data/app/controllers/standard_id/web/login_controller.rb +1 -2
- data/app/controllers/standard_id/web/verify_email/start_controller.rb +16 -9
- data/app/controllers/standard_id/web/verify_phone/start_controller.rb +16 -9
- data/app/jobs/standard_id/cleanup_all_job.rb +46 -0
- data/app/mailers/standard_id/passwordless_mailer.rb +59 -3
- data/app/models/standard_id/code_challenge.rb +4 -0
- data/app/views/standard_id/passwordless_mailer/otp_email.html.erb +5 -5
- data/app/views/standard_id/passwordless_mailer/otp_email.text.erb +5 -5
- data/app/views/standard_id/passwordless_mailer/verification_email.html.erb +24 -0
- data/app/views/standard_id/passwordless_mailer/verification_email.text.erb +12 -0
- data/config/locales/en.yml +22 -0
- data/lib/generators/standard_id/install/templates/standard_id.rb +5 -6
- data/lib/standard_id/config/schema.rb +18 -31
- data/lib/standard_id/config_schema.rb +66 -1
- data/lib/standard_id/engine.rb +1 -0
- data/lib/standard_id/events/subscribers/passwordless_delivery_subscriber.rb +51 -14
- data/lib/standard_id/otp.rb +20 -28
- data/lib/standard_id/passwordless/base_strategy.rb +39 -20
- data/lib/standard_id/passwordless/email_strategy.rb +0 -5
- data/lib/standard_id/passwordless/sms_strategy.rb +0 -4
- data/lib/standard_id/provider_registry.rb +2 -23
- data/lib/standard_id/scope_config.rb +22 -22
- data/lib/standard_id/testing/config_helpers.rb +55 -0
- data/lib/standard_id/testing/provider_examples.rb +1 -1
- data/lib/standard_id/testing.rb +1 -0
- data/lib/standard_id/version.rb +1 -1
- metadata +6 -1
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
module StandardId
|
|
2
|
+
module Testing
|
|
3
|
+
# Helpers for specs that exercise StandardId configuration defaults —
|
|
4
|
+
# chiefly the ENV fallback of provider fields (`GOOGLE_CLIENT_ID`,
|
|
5
|
+
# `APPLE_CLIENT_ID`, …).
|
|
6
|
+
#
|
|
7
|
+
# Those defaults are resolved ONCE, when the config is built at boot, so
|
|
8
|
+
# setting ENV inside a spec changes nothing on its own. `with_provider_env`
|
|
9
|
+
# sets the variables, re-resolves every field the host never assigned, runs
|
|
10
|
+
# the block, then restores both:
|
|
11
|
+
#
|
|
12
|
+
# RSpec.describe "Apple sign-in" do
|
|
13
|
+
# include StandardId::Testing::ConfigHelpers
|
|
14
|
+
#
|
|
15
|
+
# it "is enabled once APPLE_CLIENT_ID is set" do
|
|
16
|
+
# with_provider_env("APPLE_CLIENT_ID" => "com.example.web") do
|
|
17
|
+
# expect(StandardId.social_provider_enabled?(:apple)).to be(true)
|
|
18
|
+
# end
|
|
19
|
+
# end
|
|
20
|
+
# end
|
|
21
|
+
#
|
|
22
|
+
# (also callable as `StandardId::Testing.with_provider_env(...)`).
|
|
23
|
+
#
|
|
24
|
+
# A field the host assigned explicitly — even to nil — ignores ENV by
|
|
25
|
+
# design; `StandardId.config.social.assigned?(:apple_client_id)` tells the
|
|
26
|
+
# two cases apart (`key?` is true for every declared field, assigned or
|
|
27
|
+
# not).
|
|
28
|
+
module ConfigHelpers
|
|
29
|
+
# @param env [Hash{String => String, nil}] variables to set; nil unsets.
|
|
30
|
+
# Usually passed brace-less (`with_provider_env("APPLE_CLIENT_ID" => "x")`),
|
|
31
|
+
# which Ruby delivers as keywords — hence **vars.
|
|
32
|
+
# @param scope [Symbol] config scope whose defaults to re-resolve
|
|
33
|
+
# @yield with the variables set and the scope's defaults re-resolved
|
|
34
|
+
# @return [Object] the block's value
|
|
35
|
+
def with_provider_env(env = {}, scope: :social, **vars)
|
|
36
|
+
env = env.merge(vars)
|
|
37
|
+
previous = env.to_h { |name, _| [name.to_s, ENV[name.to_s]] }
|
|
38
|
+
env.each { |name, value| write_env(name.to_s, value) }
|
|
39
|
+
StandardId.config[scope].refresh_defaults!
|
|
40
|
+
yield
|
|
41
|
+
ensure
|
|
42
|
+
previous&.each { |name, value| write_env(name, value) }
|
|
43
|
+
StandardId.config[scope].refresh_defaults!
|
|
44
|
+
end
|
|
45
|
+
|
|
46
|
+
private
|
|
47
|
+
|
|
48
|
+
def write_env(name, value)
|
|
49
|
+
value.nil? ? ENV.delete(name) : ENV[name] = value.to_s
|
|
50
|
+
end
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
extend ConfigHelpers
|
|
54
|
+
end
|
|
55
|
+
end
|
|
@@ -60,7 +60,7 @@ module StandardId
|
|
|
60
60
|
# fallback keeps working for later examples.
|
|
61
61
|
def round_trip(field, value)
|
|
62
62
|
social = StandardId.config.social
|
|
63
|
-
assigned = social.
|
|
63
|
+
assigned = social.assigned?(field)
|
|
64
64
|
original = social.to_h[field.to_sym]
|
|
65
65
|
social.public_send(:"#{field}=", value)
|
|
66
66
|
social.public_send(field)
|
data/lib/standard_id/testing.rb
CHANGED
data/lib/standard_id/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: standard_id
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.43.1
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jaryl Sim
|
|
@@ -166,6 +166,7 @@ files:
|
|
|
166
166
|
- app/forms/standard_id/web/signup_form.rb
|
|
167
167
|
- app/helpers/standard_id/application_helper.rb
|
|
168
168
|
- app/jobs/standard_id/application_job.rb
|
|
169
|
+
- app/jobs/standard_id/cleanup_all_job.rb
|
|
169
170
|
- app/jobs/standard_id/cleanup_expired_authorization_codes_job.rb
|
|
170
171
|
- app/jobs/standard_id/cleanup_expired_code_challenges_job.rb
|
|
171
172
|
- app/jobs/standard_id/cleanup_expired_refresh_tokens_job.rb
|
|
@@ -199,6 +200,8 @@ files:
|
|
|
199
200
|
- app/views/standard_id/password_reset_mailer/reset_email.text.erb
|
|
200
201
|
- app/views/standard_id/passwordless_mailer/otp_email.html.erb
|
|
201
202
|
- app/views/standard_id/passwordless_mailer/otp_email.text.erb
|
|
203
|
+
- app/views/standard_id/passwordless_mailer/verification_email.html.erb
|
|
204
|
+
- app/views/standard_id/passwordless_mailer/verification_email.text.erb
|
|
202
205
|
- app/views/standard_id/web/account/edit.html.erb
|
|
203
206
|
- app/views/standard_id/web/account/show.html.erb
|
|
204
207
|
- app/views/standard_id/web/auth/callback/providers/mobile_callback.html.erb
|
|
@@ -213,6 +216,7 @@ files:
|
|
|
213
216
|
- app/views/standard_id/web/signup/show.html.erb
|
|
214
217
|
- config/brakeman.ignore
|
|
215
218
|
- config/initializers/generators.rb
|
|
219
|
+
- config/locales/en.yml
|
|
216
220
|
- config/routes/api.rb
|
|
217
221
|
- config/routes/web.rb
|
|
218
222
|
- db/migrate/20250830000000_create_standard_id_client_applications.rb
|
|
@@ -303,6 +307,7 @@ files:
|
|
|
303
307
|
- lib/standard_id/session_type_resolver.rb
|
|
304
308
|
- lib/standard_id/testing.rb
|
|
305
309
|
- lib/standard_id/testing/authentication_helpers.rb
|
|
310
|
+
- lib/standard_id/testing/config_helpers.rb
|
|
306
311
|
- lib/standard_id/testing/factories/credentials.rb
|
|
307
312
|
- lib/standard_id/testing/factories/identifiers.rb
|
|
308
313
|
- lib/standard_id/testing/factories/oauth.rb
|