Module: OCI::Auth::Signers::ServiceAccountTokenProvider

Defined in:
lib/oci/auth/signers/service_account_token_provider/sa_token_provider.rb

Overview

Service Account Token Provider Classes under this module will provide the service account token required for OKE auth provider

Defined Under Namespace

Classes: DefaultServiceAccountTokenProvider, SuppliedServiceAccountTokenProvider

Constant Summary collapse

OCI_KUBERNETES_SERVICE_ACCOUNT_TOKEN_PATH =
'/var/run/secrets/kubernetes.io/serviceaccount/token'.freeze

Class Method Summary collapse

Class Method Details

.valid_sa_token?(token) ⇒ Boolean

Returns:

  • (Boolean)


49
50
51
52
53
54
55
# File 'lib/oci/auth/signers/service_account_token_provider/sa_token_provider.rb', line 49

def self.valid_sa_token?(token)
  decoded_jwt = JWT.decode(token, nil, false)
  time_now = Time.now.to_i
  raise "Service account token does not have an 'exp' field." if decoded_jwt[0]['exp'].nil?

  time_now < decoded_jwt[0]['exp']
end