Skip to content

Commit

Permalink
chore: Ensure the subject token type matches AWS before building AwsC…
Browse files Browse the repository at this point in the history
…redentials
  • Loading branch information
rbclark committed Oct 28, 2022
1 parent a89e880 commit 994456a
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions lib/googleauth/external_account.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ module Auth
# Authenticates requests using External Account credentials, such
# as those provided by the AWS provider.
class ExternalAccountCredentials
# The subject token type used for AWS external_account credentials.
AWS_SUBJECT_TOKEN_TYPE = "urn:ietf:params:aws:token-type:aws4_request"

attr_reader :project_id
attr_reader :quota_project_id

Expand All @@ -36,6 +39,7 @@ def self.make_creds options = {}
raise "a json file is required for external account credentials" unless json_key_io
user_creds = read_json_key json_key_io

raise "aws is the only currently supported external account type" unless user_creds["subject_token_type"] == AWS_SUBJECT_TOKEN_TYPE
Google::Auth::ExternalAccount::AwsCredentials.new(
audience: user_creds["audience"],
scope: scope,
Expand Down

0 comments on commit 994456a

Please sign in to comment.