standard_singpass 0.5.0 → 0.6.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/CHANGELOG.md +15 -0
- data/README.md +16 -17
- data/lib/standard_singpass/myinfo/mock_mode_guard.rb +17 -8
- data/lib/standard_singpass/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 2ea89fcd5571a503ae9bec3dcc4c69f038e8109e68c3dfba9a119eb08efdf392
|
|
4
|
+
data.tar.gz: 43c8d9ee1f0344de72f0b6bffa181d0df12475c9f10c5ee6d80f92e9bd192a05
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: b8a3c50ad2b135eef0d4ecea3d979b21f1b223a54966114544f08aa1ce78fad0d25779e28f365c8ff57c87ae1ec03836ab1290624e11d0de3c0dbc862324d884
|
|
7
|
+
data.tar.gz: c335087baa92503937ed273d6a5528bac1310ac2636a7e529e7f9619e4414b6ce64245142760899544327b4e8138fdbaebde31205e8f7cbd44ed91aa68bfa250
|
data/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,21 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [0.6.0] - 2026-10-22
|
|
11
|
+
|
|
12
|
+
### Changed
|
|
13
|
+
|
|
14
|
+
- **The mock-mode guard follows `APP_ENVIRONMENT`, failing closed.** Without a
|
|
15
|
+
`production_env_detector`, "production deploy" is now `APP_ENVIRONMENT` when it
|
|
16
|
+
is set (only `staging`, `preview`, `development` and `test` are non-production;
|
|
17
|
+
any other value is production), else `Rails.env.production?` as before. A
|
|
18
|
+
staging box with `RAILS_ENV=production` and `APP_ENVIRONMENT=staging` boots
|
|
19
|
+
with mock mode on (reported as production-like) without detector wiring. The
|
|
20
|
+
same convention as standard_id, standard_audit and standard_health. A
|
|
21
|
+
configured detector still wins, so existing hosts are unaffected.
|
|
22
|
+
- **Requires Rails 8.1** (`rails >= 8.1, < 9`, was `>= 8.0`). Every consumer
|
|
23
|
+
app runs 8.1; 8.0 was never exercised in CI.
|
|
24
|
+
|
|
10
25
|
## [0.5.0] - 2026-09-24
|
|
11
26
|
|
|
12
27
|
**Breaking.** Removes everything 0.4.0 deprecated. No other behaviour changes.
|
data/README.md
CHANGED
|
@@ -60,8 +60,9 @@ StandardSingpass::Myinfo.configure do |c|
|
|
|
60
60
|
c.mock_mode = ENV["MYINFO_MOCK_MODE"].present?
|
|
61
61
|
|
|
62
62
|
# Optional: how the gem decides whether this deploy is real production, for
|
|
63
|
-
# the mock-mode guard. Defaults to
|
|
64
|
-
#
|
|
63
|
+
# the mock-mode guard. Defaults to APP_ENVIRONMENT (failing closed), then
|
|
64
|
+
# Rails.env.production? — see "Mock mode" below.
|
|
65
|
+
# c.production_env_detector = -> { ... }
|
|
65
66
|
end
|
|
66
67
|
```
|
|
67
68
|
|
|
@@ -115,21 +116,19 @@ opt-out — a guard you can forget to wire is a guard that isn't there.
|
|
|
115
116
|
| Anything else | yes | Silent. |
|
|
116
117
|
| Any | no | Silent. |
|
|
117
118
|
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
`Rails.error` rather than a specific error tracker, so whatever the host has
|
|
132
|
-
subscribed (Sentry included) picks it up.
|
|
119
|
+
"Production" follows the estate's `APP_ENVIRONMENT` convention (the same rule
|
|
120
|
+
standard_id, standard_audit and standard_health use): when `APP_ENVIRONMENT` is
|
|
121
|
+
set, only `staging`, `preview`, `development` and `test` are non-production and
|
|
122
|
+
any other value (a typo included) is production, so a mis-set variable fails
|
|
123
|
+
closed; when it is unset, `Rails.env.production?` decides. Staging and preview
|
|
124
|
+
deploys routinely run `RAILS_ENV=production`, so with `APP_ENVIRONMENT=staging`
|
|
125
|
+
they land in the production-like tier, where mock mode boots and is reported,
|
|
126
|
+
with no extra wiring.
|
|
127
|
+
|
|
128
|
+
`config.production_env_detector` (a callable taking no arguments, returning a
|
|
129
|
+
boolean) overrides that, for a host with a different discriminator. The
|
|
130
|
+
production-like tier reports through `Rails.error` rather than a specific error
|
|
131
|
+
tracker, so whatever the host has subscribed (Sentry included) picks it up.
|
|
133
132
|
|
|
134
133
|
## Initiating the flow
|
|
135
134
|
|
|
@@ -27,10 +27,13 @@ module StandardSingpass
|
|
|
27
27
|
# loud-but-non-fatal signal instead.
|
|
28
28
|
#
|
|
29
29
|
# "Production deploy" is decided by `config.production_env_detector` when
|
|
30
|
-
# set,
|
|
31
|
-
#
|
|
32
|
-
#
|
|
33
|
-
#
|
|
30
|
+
# set, else by the estate's APP_ENVIRONMENT convention (shared with
|
|
31
|
+
# standard_id, standard_audit and standard_health): APP_ENVIRONMENT when it
|
|
32
|
+
# is set, where only staging, preview, development and test are
|
|
33
|
+
# non-production and any other value (a typo included) is production, so a
|
|
34
|
+
# mis-set variable fails closed; else `Rails.env.production?`. A staging box
|
|
35
|
+
# with RAILS_ENV=production and APP_ENVIRONMENT=staging is therefore
|
|
36
|
+
# production-*like*, not production, with no detector wiring.
|
|
34
37
|
#
|
|
35
38
|
# Wired automatically from the engine's `after_initialize`, so a host gets
|
|
36
39
|
# the guard by configuring `mock_mode` at all. There is no opt-out: a
|
|
@@ -38,6 +41,9 @@ module StandardSingpass
|
|
|
38
41
|
module MockModeGuard
|
|
39
42
|
extend T::Sig
|
|
40
43
|
|
|
44
|
+
# APP_ENVIRONMENT values that are not production; anything else is.
|
|
45
|
+
NON_PRODUCTION_APP_ENVIRONMENTS = T.let(%w[staging preview development test].freeze, T::Array[String])
|
|
46
|
+
|
|
41
47
|
sig { void }
|
|
42
48
|
def self.check!
|
|
43
49
|
return unless StandardSingpass::Myinfo.configuration.mock_mode
|
|
@@ -50,14 +56,16 @@ module StandardSingpass
|
|
|
50
56
|
end
|
|
51
57
|
|
|
52
58
|
# Whether this deploy is real production for the purpose of the guard.
|
|
53
|
-
# Defers to config.production_env_detector when set
|
|
54
|
-
#
|
|
55
|
-
# back to Rails.env.production?.
|
|
59
|
+
# Defers to config.production_env_detector when set, else to
|
|
60
|
+
# APP_ENVIRONMENT (failing closed), else Rails.env.production?.
|
|
56
61
|
sig { returns(T::Boolean) }
|
|
57
62
|
def self.production_deploy?
|
|
58
63
|
detector = StandardSingpass::Myinfo.configuration.production_env_detector
|
|
59
64
|
return !!detector.call if detector
|
|
60
65
|
|
|
66
|
+
app_env = ENV["APP_ENVIRONMENT"].to_s.strip
|
|
67
|
+
return !NON_PRODUCTION_APP_ENVIRONMENTS.include?(app_env) unless app_env.empty?
|
|
68
|
+
|
|
61
69
|
rails_production?
|
|
62
70
|
end
|
|
63
71
|
|
|
@@ -75,7 +83,8 @@ module StandardSingpass
|
|
|
75
83
|
"identity data that is indistinguishable from verified Myinfo " \
|
|
76
84
|
"data downstream. The application refuses to boot. Unset the " \
|
|
77
85
|
"mock-mode environment variable on this deploy and redeploy. If " \
|
|
78
|
-
"this deploy is not actually production, set " \
|
|
86
|
+
"this deploy is not actually production, set APP_ENVIRONMENT " \
|
|
87
|
+
"(staging, preview, development or test) or " \
|
|
79
88
|
"config.production_env_detector so the gem can tell."
|
|
80
89
|
end
|
|
81
90
|
private_class_method :production_message
|
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: standard_singpass
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.
|
|
4
|
+
version: 0.6.0
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Jaryl Sim
|
|
@@ -15,7 +15,7 @@ dependencies:
|
|
|
15
15
|
requirements:
|
|
16
16
|
- - ">="
|
|
17
17
|
- !ruby/object:Gem::Version
|
|
18
|
-
version: '8.
|
|
18
|
+
version: '8.1'
|
|
19
19
|
- - "<"
|
|
20
20
|
- !ruby/object:Gem::Version
|
|
21
21
|
version: '9'
|
|
@@ -25,7 +25,7 @@ dependencies:
|
|
|
25
25
|
requirements:
|
|
26
26
|
- - ">="
|
|
27
27
|
- !ruby/object:Gem::Version
|
|
28
|
-
version: '8.
|
|
28
|
+
version: '8.1'
|
|
29
29
|
- - "<"
|
|
30
30
|
- !ruby/object:Gem::Version
|
|
31
31
|
version: '9'
|