Class: Capsium::Package::Authentication

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Authentication

Returns a new instance of Authentication.

Parameters:

  • path (String)


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

#configAuthenticationConfig? (readonly)

Returns the value of attribute config.

Returns:



11
12
13
# File 'lib/capsium/package/authentication.rb', line 11

def config
  @config
end

#pathString (readonly)

Returns the value of attribute path.

Returns:

  • (String)


11
12
13
# File 'lib/capsium/package/authentication.rb', line 11

def path
  @path
end

Instance Method Details

#basic_authBasicAuthConfig?

Returns:



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.

Returns:

  • (Boolean)


33
34
35
# File 'lib/capsium/package/authentication.rb', line 33

def enabled?
  !!(basic_auth&.enabled? || oauth2&.enabled?)
end

#oauth2OAuth2Config?

Returns:



28
29
30
# File 'lib/capsium/package/authentication.rb', line 28

def oauth2
  @config&.authentication&.oauth2
end

#present?Boolean

Returns:

  • (Boolean)


20
21
22
# File 'lib/capsium/package/authentication.rb', line 20

def present?
  !@config.nil?
end

#to_hashHash[String, untyped]

Returns:

  • (Hash[String, untyped])


20
# File 'sig/capsium/package/authentication.rbs', line 20

def to_hash: () -> Hash[String, untyped]

#to_jsonString

Parameters:

  • args (Object)

Returns:

  • (String)


19
# File 'sig/capsium/package/authentication.rbs', line 19

def to_json: (*untyped args) -> String