Sha256: c306edac52f7509e31019faaadcec62efd730888074ad69090399239e289bdd1

Contents?: true

Size: 893 Bytes

Versions: 8

Compression:

Stored size: 893 Bytes

Contents

module SecretsCli
  module Vault
    class Auth < SecretsCli::Vault::Base
      include SecretsCli::Helpers

      def initialize(options)
        super
        SecretsCli::Check::Vault.new(options).call
        @auth_method = ENV['VAULT_AUTH_METHOD']
        @auth_token = ENV['VAULT_AUTH_TOKEN']
        @auth_app_id = ENV['VAULT_AUTH_APP_ID']
        @auth_user_id = ENV['VAULT_AUTH_USER_ID']
      end

      private

      attr_reader :auth_token, :auth_method, :auth_app_id, :auth_user_id

      def command
        case auth_method
        when 'github'
          ::Vault.auth.github(auth_token).auth.policies
        when 'token'
          ::Vault.auth.token(auth_token).auth.policies
        when 'app_id'
          ::Vault.auth.app_id(auth_app_id, auth_user_id).auth.policies
        else
          error! "Unknown auth method #{auth_method}"
        end
      end
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
secrets_cli-1.6.0 lib/secrets_cli/vault/auth.rb
secrets_cli-1.5.0 lib/secrets_cli/vault/auth.rb
secrets_cli-1.4.2 lib/secrets_cli/vault/auth.rb
secrets_cli-1.4.1 lib/secrets_cli/vault/auth.rb
secrets_cli-1.4.0 lib/secrets_cli/vault/auth.rb
secrets_cli-1.3.3 lib/secrets_cli/vault/auth.rb
secrets_cli-1.3.2 lib/secrets_cli/vault/auth.rb
secrets_cli-1.3.1 lib/secrets_cli/vault/auth.rb