Skip to content

Commit ba4040d

Browse files
authored
Merge pull request #77 from AirHelp/support_for_aws_sso
Add support for AWS Session Token in development mode
2 parents 2300845 + af32263 commit ba4040d

File tree

5 files changed

+47
-24
lines changed

5 files changed

+47
-24
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ All notable changes to this project will be documented in this file.
44
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
55
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
66

7+
## [1.9.1] - 2024-12-30
8+
9+
- Add support for AWS Session Token in development mode
10+
711
## [1.9.0] - 2024-03-12
812

913
- Eliminate the dependency on `dotenv`. However, the application will still load `dotenv` if it is available.

Gemfile.lock

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
PATH
22
remote: .
33
specs:
4-
eventboss (1.9.0)
4+
eventboss (1.9.1)
55
aws-sdk-sns (>= 1.1.0)
66
aws-sdk-sqs (>= 1.3.0)
77
rexml (~> 3.0)
@@ -10,26 +10,25 @@ GEM
1010
remote: https://rubygems.org/
1111
specs:
1212
aws-eventstream (1.3.0)
13-
aws-partitions (1.896.0)
14-
aws-sdk-core (3.191.3)
13+
aws-partitions (1.1029.0)
14+
aws-sdk-core (3.214.1)
1515
aws-eventstream (~> 1, >= 1.3.0)
16-
aws-partitions (~> 1, >= 1.651.0)
17-
aws-sigv4 (~> 1.8)
16+
aws-partitions (~> 1, >= 1.992.0)
17+
aws-sigv4 (~> 1.9)
1818
jmespath (~> 1, >= 1.6.1)
19-
aws-sdk-sns (1.72.0)
20-
aws-sdk-core (~> 3, >= 3.191.0)
21-
aws-sigv4 (~> 1.1)
22-
aws-sdk-sqs (1.70.0)
23-
aws-sdk-core (~> 3, >= 3.191.0)
24-
aws-sigv4 (~> 1.1)
25-
aws-sigv4 (1.8.0)
19+
aws-sdk-sns (1.92.0)
20+
aws-sdk-core (~> 3, >= 3.210.0)
21+
aws-sigv4 (~> 1.5)
22+
aws-sdk-sqs (1.89.0)
23+
aws-sdk-core (~> 3, >= 3.210.0)
24+
aws-sigv4 (~> 1.5)
25+
aws-sigv4 (1.10.1)
2626
aws-eventstream (~> 1, >= 1.0.2)
2727
diff-lcs (1.5.1)
2828
dotenv (3.1.0)
2929
jmespath (1.6.2)
3030
rake (13.0.6)
31-
rexml (3.2.8)
32-
strscan (>= 3.0.9)
31+
rexml (3.4.0)
3332
rspec (3.13.0)
3433
rspec-core (~> 3.13.0)
3534
rspec-expectations (~> 3.13.0)
@@ -43,7 +42,6 @@ GEM
4342
diff-lcs (>= 1.2.0, < 2.0)
4443
rspec-support (~> 3.13.0)
4544
rspec-support (3.13.1)
46-
strscan (3.1.0)
4745

4846
PLATFORMS
4947
ruby

lib/eventboss/configuration.rb

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ class Configuration
2020
:eventboss_account_id,
2121
:aws_access_key_id,
2222
:aws_secret_access_key,
23+
:aws_session_token,
2324
:aws_sns_endpoint,
2425
:aws_sqs_endpoint,
2526
:sns_sqs_name_infix,
@@ -63,10 +64,7 @@ def sqs_client
6364
defined_or_default('sqs_client') do
6465
options = {
6566
region: eventboss_region,
66-
credentials: Aws::Credentials.new(
67-
aws_access_key_id,
68-
aws_secret_access_key
69-
)
67+
credentials: credentials
7068
}
7169
if aws_sqs_endpoint
7270
options[:endpoint] = aws_sqs_endpoint
@@ -76,6 +74,15 @@ def sqs_client
7674
end
7775
end
7876

77+
def credentials
78+
return Aws::Credentials.new(aws_access_key_id, aws_secret_access_key, aws_session_token) if development_mode?
79+
80+
Aws::Credentials.new(
81+
aws_access_key_id,
82+
aws_secret_access_key
83+
)
84+
end
85+
7986
def eventboss_region
8087
defined_or_default('eventboss_region') { ENV['EVENTBOSS_REGION'] || ENV['EVENTBUS_REGION'] }
8188
end
@@ -96,6 +103,10 @@ def aws_secret_access_key
96103
defined_or_default('aws_secret_access_key') { ENV['AWS_SECRET_ACCESS_KEY'] }
97104
end
98105

106+
def aws_session_token
107+
defined_or_default('aws_session_token') { ENV['AWS_SESSION_TOKEN'] }
108+
end
109+
99110
def aws_sqs_endpoint
100111
defined_or_default('aws_sqs_endpoint') { ENV['AWS_SQS_ENDPOINT'] }
101112
end

lib/eventboss/sns_client.rb

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,7 @@ def backend
4242
if configured?
4343
options = {
4444
region: configuration.eventboss_region,
45-
credentials: ::Aws::Credentials.new(
46-
configuration.aws_access_key_id,
47-
configuration.aws_secret_access_key
48-
)
45+
credentials: credentials
4946
}
5047
if configuration.aws_sns_endpoint
5148
options[:endpoint] = configuration.aws_sns_endpoint
@@ -59,6 +56,19 @@ def backend
5956
end
6057
end
6158

59+
def credentials
60+
return ::Aws::Credentials.new(
61+
configuration.aws_access_key_id,
62+
configuration.aws_secret_access_key,
63+
configuration.aws_session_token
64+
) if configuration.development_mode?
65+
66+
::Aws::Credentials.new(
67+
configuration.aws_access_key_id,
68+
configuration.aws_secret_access_key
69+
)
70+
end
71+
6272
def configured?
6373
!!(
6474
configuration.eventboss_region &&

lib/eventboss/version.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
module Eventboss
2-
VERSION = "1.9.0"
2+
VERSION = "1.9.1"
33
end

0 commit comments

Comments
 (0)