Class: Gem::PqTlsPolicy::Config
- Inherits:
-
Object
- Object
- Gem::PqTlsPolicy::Config
- Defined in:
- lib/rubygems_pq_tls_policy/config.rb
Constant Summary collapse
- POLICY_ENV =
"RUBYGEMS_GEM_SERVER_TLS_KEY_EXCHANGE_POLICY"- TRACE_ENV =
"RUBYGEMS_GEM_SERVER_TLS_KEY_EXCHANGE_TRACE"- ALLOWED_GROUPS_ENV =
"RUBYGEMS_GEM_SERVER_TLS_ALLOWED_GROUPS"- VALID_POLICIES =
[nil, "", "default", "off", "disabled", "pq_required"].freeze
- DEFAULT_ALLOWED_GROUPS =
["X25519MLKEM768"].freeze
Instance Attribute Summary collapse
-
#allowed_groups ⇒ Object
readonly
Returns the value of attribute allowed_groups.
-
#policy ⇒ Object
readonly
Returns the value of attribute policy.
-
#trace ⇒ Object
readonly
Returns the value of attribute trace.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
-
#initialize(env = ENV) ⇒ Config
constructor
A new instance of Config.
- #pq_required? ⇒ Boolean
- #trace? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize(env = ENV) ⇒ Config
Returns a new instance of Config.
15 16 17 18 19 |
# File 'lib/rubygems_pq_tls_policy/config.rb', line 15 def initialize(env = ENV) @policy = env[POLICY_ENV] @trace = truthy?(env[TRACE_ENV]) @allowed_groups = parse_groups(env[ALLOWED_GROUPS_ENV]) end |
Instance Attribute Details
#allowed_groups ⇒ Object (readonly)
Returns the value of attribute allowed_groups.
13 14 15 |
# File 'lib/rubygems_pq_tls_policy/config.rb', line 13 def allowed_groups @allowed_groups end |
#policy ⇒ Object (readonly)
Returns the value of attribute policy.
13 14 15 |
# File 'lib/rubygems_pq_tls_policy/config.rb', line 13 def policy @policy end |
#trace ⇒ Object (readonly)
Returns the value of attribute trace.
13 14 15 |
# File 'lib/rubygems_pq_tls_policy/config.rb', line 13 def trace @trace end |
Instance Method Details
#enabled? ⇒ Boolean
21 22 23 |
# File 'lib/rubygems_pq_tls_policy/config.rb', line 21 def enabled? ![nil, "", "default", "off", "disabled"].include?(policy) end |
#pq_required? ⇒ Boolean
25 26 27 |
# File 'lib/rubygems_pq_tls_policy/config.rb', line 25 def pq_required? policy == "pq_required" end |
#trace? ⇒ Boolean
29 30 31 |
# File 'lib/rubygems_pq_tls_policy/config.rb', line 29 def trace? trace end |
#validate! ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rubygems_pq_tls_policy/config.rb', line 33 def validate! return true if VALID_POLICIES.include?(policy) raise InvalidConfiguration, "Unsupported #{POLICY_ENV}=#{policy.inspect}. " \ "Supported values are: default, off, disabled, pq_required." end |