warden-cognito 0.3.0 → 0.3.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/.rubocop.yml +2 -0
- data/CHANGELOG.md +1 -0
- data/README.md +4 -4
- data/docker-compose.yml +0 -1
- data/lib/warden/cognito/jwk_loader.rb +3 -1
- data/lib/warden/cognito/test_helpers.rb +4 -4
- 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: 3b095b8a15788cd3682947dcde6cec111c7b83aae11e34a4d74d6b342aae3f57
|
4
|
+
data.tar.gz: 7f20572a8c319295e09977d94d6bb0a51e953e5203e285828ed6c20ad21e4642
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7cf1a2da60f1bc7cc6cbc977bb0e80f27e339360a133cc9e806c101a8f475a6de5060738598f31627fad13505e2e27d444cdad710df026b87c17077cdf77a9aa
|
7
|
+
data.tar.gz: b5ab73c7baf42f23901af0d3a485c6b4ddfef645685642f13a1a2304972f997b798d8debbbb3a12f65ac293fb8dacd20e339bb56ae40017951a0ab874edcfaa6
|
data/.rubocop.yml
CHANGED
data/CHANGELOG.md
CHANGED
@@ -5,6 +5,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
|
|
5
5
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
6
6
|
|
7
7
|
## [Unreleased]
|
8
|
+
- Allow selection of `user_pool` when generating a jwt through the test helper
|
8
9
|
|
9
10
|
## [0.3.0]
|
10
11
|
- **Breaking Changes**: Configuration explicitly moved to `user_pools` object
|
data/README.md
CHANGED
@@ -82,12 +82,12 @@ module Helpers
|
|
82
82
|
end
|
83
83
|
end
|
84
84
|
|
85
|
-
def auth_headers_for_user(user, headers = {})
|
86
|
-
Warden::Cognito::TestHelpers.auth_headers(headers, user)
|
85
|
+
def auth_headers_for_user(user, pool_identifier, headers = {})
|
86
|
+
Warden::Cognito::TestHelpers.auth_headers(headers, user, pool_identifier)
|
87
87
|
end
|
88
88
|
|
89
|
-
def jwt_for_user(user)
|
90
|
-
auth_headers_for_user(user)[:Authorization].split[1]
|
89
|
+
def jwt_for_user(user, pool_identifier)
|
90
|
+
auth_headers_for_user(user, pool_identifier)[:Authorization].split[1]
|
91
91
|
end
|
92
92
|
end
|
93
93
|
end
|
data/docker-compose.yml
CHANGED
@@ -5,7 +5,9 @@ module Warden
|
|
5
5
|
include HasUserPoolIdentifier
|
6
6
|
|
7
7
|
def jwt_issuer
|
8
|
-
|
8
|
+
return "#{user_pool.identifier}-#{jwk.issuer}" if jwk.issuer.present?
|
9
|
+
|
10
|
+
"https://cognito-idp.#{user_pool.region}.amazonaws.com/#{user_pool.pool_id}"
|
9
11
|
end
|
10
12
|
|
11
13
|
def issued?(token)
|
@@ -12,8 +12,8 @@ module Warden
|
|
12
12
|
Warden::Cognito.config.jwk = { key: jwk, issuer: local_issuer }
|
13
13
|
end
|
14
14
|
|
15
|
-
def auth_headers(headers, user)
|
16
|
-
headers.merge(Authorization: "Bearer #{generate_token(user)}")
|
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)}")
|
17
17
|
end
|
18
18
|
|
19
19
|
def local_issuer
|
@@ -22,10 +22,10 @@ module Warden
|
|
22
22
|
|
23
23
|
private
|
24
24
|
|
25
|
-
def generate_token(user)
|
25
|
+
def generate_token(user, pool_identifier)
|
26
26
|
payload = { sub: user.object_id,
|
27
27
|
"#{identifying_attribute}": user.cognito_id,
|
28
|
-
iss: local_issuer }
|
28
|
+
iss: "#{pool_identifier}-#{local_issuer}" }
|
29
29
|
headers = { kid: jwk.kid }
|
30
30
|
JWT.encode(payload, jwk.keypair, 'RS256', headers)
|
31
31
|
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.1
|
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-02-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|