aws-msk-iam-sasl-signer 0.1.0 → 0.1.1
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 +4 -4
- data/README.md +16 -65
- data/lib/aws-msk-iam-sasl-signer/version.rb +1 -1
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f0d7e320950177e18b7c8d5fe2b73885caba82e0ae9e2412c2a9fa4774831aff
|
4
|
+
data.tar.gz: 1eea46bda5a52a5025fa511a693ed578bd1b422367e7d9085d52fd2b6e77971f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 267053e91070bfdc18b8de061b39fc455c005ec000cb94d2eb1e99b1776171f58b8e9ee81fdf93b342c4f44564787bae75c813c2df1ac3d74d6067740f597c59
|
7
|
+
data.tar.gz: 18a7053eb427399aa2c7b161f0f01ccc6b7f7aa42384bf48c47591102695d853a0ea16cc5b84151de52f2be568c35b1c45bb212692bd64297fa1262f3ec2b8f4
|
data/README.md
CHANGED
@@ -34,72 +34,10 @@ This is the preferred method to install aws-msk-iam-sasl-signer-ruby, as it will
|
|
34
34
|
gem install aws-msk-iam-sasl-signer
|
35
35
|
```
|
36
36
|
|
37
|
-
##
|
37
|
+
## Examples
|
38
38
|
|
39
|
-
|
40
|
-
|
41
|
-
# frozen_string_literal: true
|
42
|
-
require "aws-msk-iam-sasl-signer"
|
43
|
-
require "json"
|
44
|
-
require "rdkafka"
|
45
|
-
|
46
|
-
KAFKA_TOPIC = ENV['KAFKA_TOPIC']
|
47
|
-
KAFKA_BOOTSTRAP_SERVERS = ENV['KAFKA_BOOTSTRAP_SERVERS']
|
48
|
-
|
49
|
-
kafka_config = {
|
50
|
-
"bootstrap.servers": KAFKA_BOOTSTRAP_SERVERS,
|
51
|
-
"security.protocol": 'sasl_ssl',
|
52
|
-
"sasl.mechanisms": 'OAUTHBEARER',
|
53
|
-
"client.id": 'ruby-producer',
|
54
|
-
}
|
55
|
-
|
56
|
-
def refresh_token(client, config)
|
57
|
-
signer = AwsMskIamSaslSigner::MSKTokenProvider.new(region: 'us-east-1')
|
58
|
-
auth_token = signer.generate_auth_token
|
59
|
-
|
60
|
-
error_buffer = FFI::MemoryPointer.from_string(' ' * 256)
|
61
|
-
response = Rdkafka::Bindings.rd_kafka_oauthbearer_set_token(
|
62
|
-
client, auth_token.token, auth_token.expiration_time_ms, 'kafka-cluster', nil, 0, error_buffer, 256
|
63
|
-
)
|
64
|
-
return unless response != 0
|
65
|
-
|
66
|
-
Rdkafka::Bindings.rd_kafka_oauthbearer_set_token_failure(client,
|
67
|
-
"Failed to set token: #{error_buffer.read_string}")
|
68
|
-
|
69
|
-
end
|
70
|
-
|
71
|
-
# set the token refresh callback
|
72
|
-
Rdkafka::Config.oauthbearer_token_refresh_callback = method(:refresh_token)
|
73
|
-
producer = Rdkafka::Config.new(kafka_config).producer
|
74
|
-
|
75
|
-
# seed the token
|
76
|
-
# events_poll will invoke all registered callbacks, of which oauthbearer_token_refresh_callback is one
|
77
|
-
|
78
|
-
consumer = Rdkafka::Config.new(kafka_config).consumer
|
79
|
-
consumer.events_poll
|
80
|
-
|
81
|
-
# produce some messages
|
39
|
+
- [rdkafka](examples/rdkafka/README.md) (using rdkafka gem)
|
82
40
|
|
83
|
-
Payload = Data.define(:device_id, :creation_timestamp, :temperature)
|
84
|
-
|
85
|
-
loop do
|
86
|
-
payload = Payload.new(
|
87
|
-
device_id: '1234',
|
88
|
-
creation_timestamp: Time.now.to_i,
|
89
|
-
temperature: rand(0..100)
|
90
|
-
)
|
91
|
-
|
92
|
-
handle = producer.produce(
|
93
|
-
topic: KAFKA_TOPIC,
|
94
|
-
payload: payload.to_h.to_json,
|
95
|
-
key: "ruby-kafka-#{rand(0..999)}"
|
96
|
-
)
|
97
|
-
handle.wait(max_wait_timeout: 10)
|
98
|
-
|
99
|
-
sleep(10)
|
100
|
-
end
|
101
|
-
|
102
|
-
```
|
103
41
|
|
104
42
|
In order to use a named profile to generate the token, replace the `generate_auth_token` function with code below:
|
105
43
|
|
@@ -110,7 +48,6 @@ In order to use a named profile to generate the token, replace the `generate_aut
|
|
110
48
|
)
|
111
49
|
```
|
112
50
|
|
113
|
-
|
114
51
|
In order to use a role arn to generate the token, replace the `generate_auth_token` function with code below:
|
115
52
|
|
116
53
|
```ruby
|
@@ -201,3 +138,17 @@ Everyone interacting in this project’s codebases, issue trackers, chat rooms a
|
|
201
138
|
## Contribution guide
|
202
139
|
|
203
140
|
Pull requests are welcome!
|
141
|
+
|
142
|
+
## Releasing
|
143
|
+
|
144
|
+
- create PR with version change
|
145
|
+
- bump version in `lib/aws-msk-iam-sasl-signer/version.rb`
|
146
|
+
- approve and merge
|
147
|
+
|
148
|
+
```bash
|
149
|
+
git checkout main
|
150
|
+
git pull origin main
|
151
|
+
VERSION="v$(grep -o 'VERSION = "[^"]*' lib/aws-msk-iam-sasl-signer/version.rb | grep -o '[^"]*$')"
|
152
|
+
git tag -a ${VERSION} -m "${VERSION}"
|
153
|
+
git push origin ${VERSION}
|
154
|
+
```
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: aws-msk-iam-sasl-signer
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- bruce szalwinski
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-09-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: aws-sdk-kafka
|
@@ -38,7 +38,7 @@ dependencies:
|
|
38
38
|
- - ">="
|
39
39
|
- !ruby/object:Gem::Version
|
40
40
|
version: '0'
|
41
|
-
description:
|
41
|
+
description:
|
42
42
|
email:
|
43
43
|
- bruce.szalwinski@hotelengine.com
|
44
44
|
executables:
|
@@ -64,7 +64,7 @@ metadata:
|
|
64
64
|
source_code_uri: https://github.com/bruce-szalwinski-he/aws-msk-iam-sasl-signer-ruby
|
65
65
|
homepage_uri: https://github.com/bruce-szalwinski-he/aws-msk-iam-sasl-signer-ruby
|
66
66
|
rubygems_mfa_required: 'true'
|
67
|
-
post_install_message:
|
67
|
+
post_install_message:
|
68
68
|
rdoc_options: []
|
69
69
|
require_paths:
|
70
70
|
- lib
|
@@ -79,8 +79,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
79
79
|
- !ruby/object:Gem::Version
|
80
80
|
version: '0'
|
81
81
|
requirements: []
|
82
|
-
rubygems_version: 3.5.
|
83
|
-
signing_key:
|
82
|
+
rubygems_version: 3.5.16
|
83
|
+
signing_key:
|
84
84
|
specification_version: 4
|
85
85
|
summary: MSK Library in Ruby for SASL/OAUTHBEARER Auth
|
86
86
|
test_files: []
|