Module: Legate::CLI::AuthCommandHelpers
- Included in:
- AuthCredentialCommands, AuthMappingCommands, AuthSchemeCommands
- Defined in:
- lib/legate/cli/auth_commands.rb
Overview
Helper module for auth command formatting
Instance Method Summary collapse
-
#auth_manager ⇒ Object
Ensure auth manager is ready.
-
#credential_type_description(auth_type) ⇒ Object
Get credential type description.
-
#mask_sensitive_value(value) ⇒ Object
Mask sensitive values for display.
-
#print_header(text) ⇒ Object
Print styled header.
-
#print_row(label, value, indent: 2) ⇒ Object
Print styled table row.
-
#scheme_type_description(scheme_type) ⇒ Object
Get scheme type description.
-
#sensitive_field?(name) ⇒ Boolean
Sensitive field names.
Instance Method Details
#auth_manager ⇒ Object
Ensure auth manager is ready
69 70 71 72 73 74 75 |
# File 'lib/legate/cli/auth_commands.rb', line 69 def auth_manager @auth_manager ||= begin manager = Legate::Auth::Manager.instance manager.load_from_store manager end end |
#credential_type_description(auth_type) ⇒ Object
Get credential type description
39 40 41 42 43 44 45 46 47 48 49 50 |
# File 'lib/legate/cli/auth_commands.rb', line 39 def credential_type_description(auth_type) case auth_type.to_sym when :api_key then 'API Key' when :http_bearer then 'Bearer Token' when :oauth2 then 'OAuth2 Client' when :oidc then 'OIDC Client' when :service_account then 'Service Account' when :google_service_account then 'Google Service Account' when :basic then 'Basic Auth' else auth_type.to_s end end |
#mask_sensitive_value(value) ⇒ Object
Mask sensitive values for display
14 15 16 17 18 19 20 21 22 23 |
# File 'lib/legate/cli/auth_commands.rb', line 14 def mask_sensitive_value(value) return '(not set)' if value.nil? || value.empty? return value if value.start_with?('ENV:') # Show env var references as-is if value.length <= 8 '********' else "#{value[0, 4]}********#{value[-4..]}" end end |
#print_header(text) ⇒ Object
Print styled header
58 59 60 |
# File 'lib/legate/cli/auth_commands.rb', line 58 def print_header(text) puts ::CLI::UI.fmt("{{bold:#{text}}}") end |
#print_row(label, value, indent: 2) ⇒ Object
Print styled table row
63 64 65 66 |
# File 'lib/legate/cli/auth_commands.rb', line 63 def print_row(label, value, indent: 2) padding = ' ' * indent puts "#{padding}#{::CLI::UI.fmt("{{cyan:#{label}:}}")} #{value}" end |
#scheme_type_description(scheme_type) ⇒ Object
Get scheme type description
26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/legate/cli/auth_commands.rb', line 26 def scheme_type_description(scheme_type) case scheme_type.to_sym when :api_key then 'API Key authentication' when :http_bearer then 'HTTP Bearer token' when :oauth2 then 'OAuth 2.0 flow' when :oidc, :openid_connect then 'OpenID Connect' when :service_account then 'Service Account' when :google_service_account then 'Google Service Account' else scheme_type.to_s end end |
#sensitive_field?(name) ⇒ Boolean
Sensitive field names
53 54 55 |
# File 'lib/legate/cli/auth_commands.rb', line 53 def sensitive_field?(name) %i[api_key client_secret bearer_token password private_key service_account_key token].include?(name.to_sym) end |