Class: Capsium::Package::Authentication
- Inherits:
-
Object
- Object
- Capsium::Package::Authentication
- Extended by:
- Forwardable
- Defined in:
- lib/capsium/package/authentication.rb,
sig/capsium/package/authentication.rbs
Overview
Loads a package's authentication.json (ARCHITECTURE.md section 4b).
Instance Attribute Summary collapse
-
#config ⇒ AuthenticationConfig?
readonly
Returns the value of attribute config.
-
#path ⇒ String
readonly
Returns the value of attribute path.
Instance Method Summary collapse
- #basic_auth ⇒ BasicAuthConfig?
-
#enabled? ⇒ Boolean
Whether any authentication method is enabled.
-
#initialize(path) ⇒ Authentication
constructor
A new instance of Authentication.
- #oauth2 ⇒ OAuth2Config?
- #present? ⇒ Boolean
- #to_hash ⇒ Hash[String, untyped]
- #to_json ⇒ String
Constructor Details
#initialize(path) ⇒ Authentication
Returns a new instance of Authentication.
15 16 17 18 |
# File 'lib/capsium/package/authentication.rb', line 15 def initialize(path) @path = path @config = File.exist?(path) ? AuthenticationConfig.from_json(File.read(path)) : nil end |
Instance Attribute Details
#config ⇒ AuthenticationConfig? (readonly)
Returns the value of attribute config.
11 12 13 |
# File 'lib/capsium/package/authentication.rb', line 11 def config @config end |
#path ⇒ String (readonly)
Returns the value of attribute path.
11 12 13 |
# File 'lib/capsium/package/authentication.rb', line 11 def path @path end |
Instance Method Details
#basic_auth ⇒ BasicAuthConfig?
24 25 26 |
# File 'lib/capsium/package/authentication.rb', line 24 def basic_auth @config&.authentication&.basic_auth end |
#enabled? ⇒ Boolean
Whether any authentication method is enabled.
33 34 35 |
# File 'lib/capsium/package/authentication.rb', line 33 def enabled? !!(basic_auth&.enabled? || oauth2&.enabled?) end |
#oauth2 ⇒ OAuth2Config?
28 29 30 |
# File 'lib/capsium/package/authentication.rb', line 28 def oauth2 @config&.authentication&.oauth2 end |
#present? ⇒ Boolean
20 21 22 |
# File 'lib/capsium/package/authentication.rb', line 20 def present? !@config.nil? end |
#to_hash ⇒ Hash[String, untyped]
20 |
# File 'sig/capsium/package/authentication.rbs', line 20
def to_hash: () -> Hash[String, untyped]
|
#to_json ⇒ String
19 |
# File 'sig/capsium/package/authentication.rbs', line 19
def to_json: (*untyped args) -> String
|