warden-cognito 0.3.2 → 0.3.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: 2687b41c309c906143a2e73424611d0d7460fddc76a45c0c4532fa1582651c45
4
- data.tar.gz: 7c49b8e8ff55ddd17264b1c7027fb1657d09b83e470d90c031ff9b25fcb48080
3
+ metadata.gz: 40fa2362bb3ef3268cbecf7b60d3570ed4883e431c1705e8f9c90f8478eaac56
4
+ data.tar.gz: f29115a0f11806c184f78070b468b2e5841f8ab609ff780d1fa94a87ef3d8c16
5
5
  SHA512:
6
- metadata.gz: 96a062130b58bb4fbd10fb98d0f811ff7dd67aa23e353bf5cbcb2fd8361b9189cf0799de0c1f0a935c0019c39a5eadaf85fd6270d988349f1ee4a278e8c141c1
7
- data.tar.gz: 488e89f8eed675676001a76ff068121a118174b65f35aa695910330d5d431917c142b8e95f1bc9f2a5e0c93e0f82f2d43ebe737a2e4b4487fc1a92c889479ab0
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.2...HEAD
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
- headers.merge(Authorization: "Bearer #{generate_token(user, pool_identifier)}")
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 = { sub: user.object_id,
27
- "#{identifying_attribute}": user.cognito_id,
28
- iss: "#{pool_identifier}-#{local_issuer}" }
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
@@ -1,5 +1,5 @@
1
1
  module Warden
2
2
  module Cognito
3
- VERSION = '0.3.2'.freeze
3
+ VERSION = '0.3.3'.freeze
4
4
  end
5
5
  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.2
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-02-10 00:00:00.000000000 Z
12
+ date: 2021-05-06 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: activesupport