stripe-workload-identity 0.1.0.pre.alpha.2 → 0.1.0.pre.alpha.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 87df79528af1ed8b85709106fca3e8b20170a91307d069d1a3126d02a8a94761
4
- data.tar.gz: 1ecf03cd875a3c5be90e012e592b2e8f1a5486fd0e1add949a51b411ddae70d8
3
+ metadata.gz: 368e2a8a2330ed088e3091c43c7044c24823fafce2ac8bdeefa2a61f11bb38bd
4
+ data.tar.gz: 85db2f928e744c204455a2349f2c95b2201ca983b94902c323047b17fd3e2bea
5
5
  SHA512:
6
- metadata.gz: 47c6b5d538064c8a52799497bd42066395b5053ac28880db8cacab6fe21f51646cda063a4e427e6774d8063624a8dbacff77f97596df32b3ab4347a3c25ddaf7
7
- data.tar.gz: e4a5645f6dbeec1a219a13a1ac21c46a6560c359f89d0cd3e7e4ed5b7cf150200e0f6184d2f7c11eda1a085798e4ec5991afd6cf042ba3e5e274ded84c5ea0f9
6
+ metadata.gz: 1c084a957d50694a069cc224dcf8430655ab9aed8f71b3b8c0237900bb45c8082628bab5b3df6b50dcbe6851f88aaf624416b84afeda588a7050bb4a3578c743
7
+ data.tar.gz: e313b8edace998c4d66e7bbce41468ea303fe31ec5da8fe7f419b2e1a5df8292abd2a71ac4342d6b4d5c43056dd393a87af5b5b2df671cd75be4f23f839bced5
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Stripe
4
4
  module WorkloadIdentity
5
- VERSION = "0.1.0-alpha.2"
5
+ VERSION = "0.1.0-alpha.3"
6
6
  end
7
7
  end
@@ -1,7 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require "googleauth"
4
-
5
3
  require "stripe/workload_identity/version"
6
4
 
7
5
  module Stripe
@@ -22,6 +20,8 @@ module Stripe
22
20
  end
23
21
 
24
22
  def identity_assertion
23
+ require "googleauth"
24
+
25
25
  credentials = Google::Auth::GCECredentials.new(token_type: :id_token, target_audience: AUDIENCE)
26
26
 
27
27
  begin
@@ -40,5 +40,52 @@ module Stripe
40
40
  token
41
41
  end
42
42
  end
43
+
44
+ # Implements the workload identity provider, matching the
45
+ # type expected by `Stripe::StripeClient.for_workload_identity`
46
+ class AwsWorkloadIdentity
47
+ DEFAULT_SIGNING_ALGORITHM = "ES384"
48
+
49
+ SETUP_GUIDANCE = "Check that the process is running on AWS infrastructure with an identity that is " \
50
+ "allowed to call sts:GetWebIdentityToken, and that a region is configured (the " \
51
+ "operation is not available on the STS global endpoint). For local development, unit " \
52
+ "tests, and CI that are not running on AWS, use a Stripe API key with " \
53
+ "Stripe::StripeClient.new(...) instead."
54
+ private_constant :SETUP_GUIDANCE
55
+
56
+ # `audience` and `signing_algorithm` override the JWT requested from AWS STS; only set
57
+ # these if Stripe has told you to use different values. Any other keyword is forwarded
58
+ # to `Aws::STS::Client.new`.
59
+ def initialize(audience: AUDIENCE, signing_algorithm: DEFAULT_SIGNING_ALGORITHM, **sts_client_options)
60
+ @audience = audience
61
+ @signing_algorithm = signing_algorithm
62
+ @sts_client_options = sts_client_options
63
+ end
64
+
65
+ def provider
66
+ "aws"
67
+ end
68
+
69
+ def identity_assertion
70
+ require "aws-sdk-core"
71
+
72
+ client = Aws::STS::Client.new(**@sts_client_options)
73
+
74
+ begin
75
+ response = client.get_web_identity_token(audience: [@audience], signing_algorithm: @signing_algorithm)
76
+ rescue StandardError
77
+ raise Error, "Unable to obtain an AWS workload identity assertion: sts:GetWebIdentityToken failed. " \
78
+ "#{SETUP_GUIDANCE}"
79
+ end
80
+
81
+ token = response.web_identity_token
82
+ if token.nil? || token.empty?
83
+ raise Error, "Unable to obtain an AWS workload identity assertion: sts:GetWebIdentityToken " \
84
+ "returned no WebIdentityToken. #{SETUP_GUIDANCE}"
85
+ end
86
+
87
+ token
88
+ end
89
+ end
43
90
  end
44
91
  end
@@ -16,5 +16,20 @@ module Stripe
16
16
  sig { override.returns(String) }
17
17
  def identity_assertion; end
18
18
  end
19
+
20
+ class AwsWorkloadIdentity
21
+ include ::Stripe::WorkloadIdentity::Provider
22
+
23
+ DEFAULT_SIGNING_ALGORITHM = T.let(T.unsafe(nil), String)
24
+
25
+ sig { params(audience: String, signing_algorithm: String, sts_client_options: T.untyped).void }
26
+ def initialize(audience: AUDIENCE, signing_algorithm: DEFAULT_SIGNING_ALGORITHM, **sts_client_options); end
27
+
28
+ sig { override.returns(String) }
29
+ def provider; end
30
+
31
+ sig { override.returns(String) }
32
+ def identity_assertion; end
33
+ end
19
34
  end
20
35
  end
metadata CHANGED
@@ -1,15 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: stripe-workload-identity
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.0.pre.alpha.2
4
+ version: 0.1.0.pre.alpha.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Stripe
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2026-10-21 00:00:00.000000000 Z
11
+ date: 2026-11-03 00:00:00.000000000 Z
12
12
  dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: aws-sdk-core
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.238'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.238'
13
27
  - !ruby/object:Gem::Dependency
14
28
  name: googleauth
15
29
  requirement: !ruby/object:Gem::Requirement
@@ -24,10 +38,9 @@ dependencies:
24
38
  - - "~>"
25
39
  - !ruby/object:Gem::Version
26
40
  version: '1.8'
27
- description: Lets Stripe::StripeClient.for_workload_identity authenticate on Google
28
- Cloud environments with a compatible metadata identity-token endpoint, using a Google-signed
29
- identity token instead of a long-lived API key. Does not depend on the `stripe`
30
- gem.
41
+ description: Lets Stripe::StripeClient.for_workload_identity authenticate on AWS or
42
+ Google Cloud environments using a cloud-signed identity token instead of a long-lived
43
+ API key. Does not depend on the `stripe` gem.
31
44
  email: support@stripe.com
32
45
  executables: []
33
46
  extensions: []
@@ -64,5 +77,5 @@ requirements: []
64
77
  rubygems_version: 3.3.27
65
78
  signing_key:
66
79
  specification_version: 4
67
- summary: GCP workload identity provider for the Stripe Ruby bindings
80
+ summary: AWS and GCP workload identity providers for the Stripe Ruby bindings
68
81
  test_files: []