Class: OCI::Auth::Signers::ServiceAccountTokenProvider::DefaultServiceAccountTokenProvider
- Inherits:
-
Object
- Object
- OCI::Auth::Signers::ServiceAccountTokenProvider::DefaultServiceAccountTokenProvider
- Defined in:
- lib/oci/auth/signers/service_account_token_provider/sa_token_provider.rb
Overview
Class that provides the service account token from the default location
Instance Method Summary collapse
-
#initialize ⇒ DefaultServiceAccountTokenProvider
constructor
A new instance of DefaultServiceAccountTokenProvider.
- #override_sa_token_path(new_token_path) ⇒ Object
- #service_account_token ⇒ Object
Constructor Details
#initialize ⇒ DefaultServiceAccountTokenProvider
Returns a new instance of DefaultServiceAccountTokenProvider.
15 16 17 |
# File 'lib/oci/auth/signers/service_account_token_provider/sa_token_provider.rb', line 15 def initialize @token_path = OCI_KUBERNETES_SERVICE_ACCOUNT_TOKEN_PATH end |
Instance Method Details
#override_sa_token_path(new_token_path) ⇒ Object
19 20 21 |
# File 'lib/oci/auth/signers/service_account_token_provider/sa_token_provider.rb', line 19 def override_sa_token_path(new_token_path) @token_path = new_token_path end |
#service_account_token ⇒ Object
23 24 25 26 27 28 29 30 31 32 |
# File 'lib/oci/auth/signers/service_account_token_provider/sa_token_provider.rb', line 23 def service_account_token sa_token = '' File.open(@token_path, 'r') do |file| sa_token = file.read.strip end is_sa_token_valid = OCI::Auth::Signers::ServiceAccountTokenProvider.valid_sa_token?(sa_token) raise "Service account token at #{@token_path} has expired." if is_sa_token_valid == false sa_token end |