warden-cognito 0.3.2 → 0.3.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +5 -1
- data/lib/warden/cognito/test_helpers.rb +11 -6
- data/lib/warden/cognito/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 40fa2362bb3ef3268cbecf7b60d3570ed4883e431c1705e8f9c90f8478eaac56
|
4
|
+
data.tar.gz: f29115a0f11806c184f78070b468b2e5841f8ab609ff780d1fa94a87ef3d8c16
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10d0c0098ef31565f797f73c210a2634d02f641fcff5736bc28a4a44bd749e68edc165c2fbc691f86454d1fa17a8ff21caddcafdf02e17f1dd47b5d9ed05f83c
|
7
|
+
data.tar.gz: d3405f6873a37d95d119f88150c6e5e4c3ff03afe440acef16daafcd78368562e770df42e2ed64350ead50854965eae8e8c93ca3b6836ba4c756d6601ab6f175
|
data/CHANGELOG.md
CHANGED
@@ -6,6 +6,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
8
|
|
9
|
+
## [0.3.3]
|
10
|
+
- Improve test helpers to include `jti` and `exp` claims and accept user-supplied claims.
|
11
|
+
|
9
12
|
## [0.3.2]
|
10
13
|
- Fix - specify region on scoped aws client
|
11
14
|
|
@@ -33,7 +36,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
33
36
|
|
34
37
|
- Scratching the gem
|
35
38
|
|
36
|
-
[Unreleased]: https://github.com/barkibu/warden-cognito/compare/v0.3.
|
39
|
+
[Unreleased]: https://github.com/barkibu/warden-cognito/compare/v0.3.3...HEAD
|
40
|
+
[0.3.3]: https://github.com/barkibu/warden-cognito/compare/v0.3.2...v0.3.3
|
37
41
|
[0.3.2]: https://github.com/barkibu/warden-cognito/compare/v0.3.1...v0.3.2
|
38
42
|
[0.3.1]: https://github.com/barkibu/warden-cognito/compare/v0.3.0...v0.3.1
|
39
43
|
[0.3.0]: https://github.com/barkibu/warden-cognito/compare/v0.2.3...v0.3.0
|
@@ -12,8 +12,9 @@ module Warden
|
|
12
12
|
Warden::Cognito.config.jwk = { key: jwk, issuer: local_issuer }
|
13
13
|
end
|
14
14
|
|
15
|
-
def auth_headers(headers, user, pool_identifier = Warden::Cognito.config.user_pools.first.identifier
|
16
|
-
|
15
|
+
def auth_headers(headers, user, pool_identifier = Warden::Cognito.config.user_pools.first.identifier,
|
16
|
+
claims = {})
|
17
|
+
headers.merge(Authorization: "Bearer #{generate_token(user, pool_identifier, claims)}")
|
17
18
|
end
|
18
19
|
|
19
20
|
def local_issuer
|
@@ -22,10 +23,14 @@ module Warden
|
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
|
-
def generate_token(user, pool_identifier)
|
26
|
-
payload = {
|
27
|
-
|
28
|
-
|
26
|
+
def generate_token(user, pool_identifier, claims = {})
|
27
|
+
payload = {
|
28
|
+
sub: user.object_id,
|
29
|
+
"#{identifying_attribute}": user.cognito_id,
|
30
|
+
iss: "#{pool_identifier}-#{local_issuer}",
|
31
|
+
jti: SecureRandom.uuid,
|
32
|
+
exp: 1.hour.from_now.to_i
|
33
|
+
}.merge(claims)
|
29
34
|
headers = { kid: jwk.kid }
|
30
35
|
JWT.encode(payload, jwk.keypair, 'RS256', headers)
|
31
36
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: warden-cognito
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.3.
|
4
|
+
version: 0.3.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juan F. Pérez
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: exe
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-
|
12
|
+
date: 2021-05-06 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|