Class: RosettAi::Mcp::HttpSecurityConfig::AuthConfig
- Inherits:
-
Object
- Object
- RosettAi::Mcp::HttpSecurityConfig::AuthConfig
- Defined in:
- lib/rosett_ai/mcp/http_security_config.rb
Overview
Authentication sub-configuration.
Constant Summary collapse
- DEFAULT_KEYFILE_NAME =
'rosett-ai-mcp-keys.yml'
Instance Attribute Summary collapse
-
#api_key_env ⇒ Object
Returns the value of attribute api_key_env.
-
#key_source ⇒ Object
Returns the value of attribute key_source.
-
#keyfile_path ⇒ Object
Returns the value of attribute keyfile_path.
-
#type ⇒ Object
Returns the value of attribute type.
Instance Method Summary collapse
- #apply(hash) ⇒ Object
-
#initialize ⇒ AuthConfig
constructor
A new instance of AuthConfig.
-
#resolved_key_source ⇒ String
Resolve the effective key source.
Constructor Details
#initialize ⇒ AuthConfig
Returns a new instance of AuthConfig.
51 52 53 54 55 56 |
# File 'lib/rosett_ai/mcp/http_security_config.rb', line 51 def initialize @type = 'api_key' @key_source = 'auto' @keyfile_path = DEFAULT_KEYFILE_NAME @api_key_env = 'RAI_MCP_API_KEY' end |
Instance Attribute Details
#api_key_env ⇒ Object
Returns the value of attribute api_key_env.
47 48 49 |
# File 'lib/rosett_ai/mcp/http_security_config.rb', line 47 def api_key_env @api_key_env end |
#key_source ⇒ Object
Returns the value of attribute key_source.
47 48 49 |
# File 'lib/rosett_ai/mcp/http_security_config.rb', line 47 def key_source @key_source end |
#keyfile_path ⇒ Object
Returns the value of attribute keyfile_path.
47 48 49 |
# File 'lib/rosett_ai/mcp/http_security_config.rb', line 47 def keyfile_path @keyfile_path end |
#type ⇒ Object
Returns the value of attribute type.
47 48 49 |
# File 'lib/rosett_ai/mcp/http_security_config.rb', line 47 def type @type end |
Instance Method Details
#apply(hash) ⇒ Object
67 68 69 70 71 72 73 74 |
# File 'lib/rosett_ai/mcp/http_security_config.rb', line 67 def apply(hash) return unless hash.is_a?(Hash) @type = hash['type'] if hash['type'] @key_source = hash['key_source'] if hash['key_source'] @keyfile_path = hash['keyfile_path'] if hash['keyfile_path'] @api_key_env = hash['api_key_env'] if hash['api_key_env'] end |
#resolved_key_source ⇒ String
Resolve the effective key source.
61 62 63 64 65 |
# File 'lib/rosett_ai/mcp/http_security_config.rb', line 61 def resolved_key_source return @key_source unless @key_source == 'auto' File.exist?(File.(@keyfile_path)) ? 'keyfile' : 'env' end |