jwt-aws-kms 1.0.0 → 1.1.0

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: 13309417bcacef146c8de8889e0c7d2cee14c8b19d50257f212964bb25af2067
4
- data.tar.gz: f00ad6f098b8b95ed5098fabc8eabfd21461777234e3c50a0368adb1d48ee565
3
+ metadata.gz: e64c3474f2ea542d27a5fa1ab387eb8f2e7a0062b5c7b44150a6cc6fa893f7b1
4
+ data.tar.gz: 051aa376be6287c1f9de6af10b367f371c5b2598971178d9b2c6f8e8825e8e3a
5
5
  SHA512:
6
- metadata.gz: 1d9fa5aa566d3f6f27a9c102a313e47ff3a01753f891ac04b860aa6ed3af07ccc3540039c8224a9c8d7ee267e1ee8430facd0b5540fafab285533be0d08e398f
7
- data.tar.gz: 2c0969e4d242a45b266d9edad30ef24ad2794f5def3b46ba180dca1f6e07a5a8bb4a19d1572844e40d023c51e247318aa9d9b2dea4f5032385ae712d4f3bbb0a
6
+ metadata.gz: e4a06791919ae10552641fbd2d75dd065b54aa3245ecf6d7f58fc3017d39b17eeac981466262d4d4e2050996b929cabe28844f83fab11f4e85a445758d0b1b59
7
+ data.tar.gz: 345f064a775dbbad68863973ba056eea89dc6b524c11669ca9bf5727a2267538a64faf702545d80674ea2d5236c27a1877964dcd52bf51e03a8150943a528da0
@@ -1,3 +1,3 @@
1
1
  {
2
- ".": "1.0.0"
2
+ ".": "1.1.0"
3
3
  }
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Changelog
2
2
 
3
+ ## [1.1.0](https://github.com/anakinj/jwt-aws-kms/compare/v1.0.0...v1.1.0) (2024-09-28)
4
+
5
+
6
+ ### Features
7
+
8
+ * Allow replacing default algorithms with AWS KMS versions ([#7](https://github.com/anakinj/jwt-aws-kms/issues/7)) ([d6cfe4f](https://github.com/anakinj/jwt-aws-kms/commit/d6cfe4f9bb0ec23daaee771e8692a4410aef393e))
9
+
3
10
  ## [1.0.0](https://github.com/anakinj/jwt-aws-kms/compare/v0.6.0...v1.0.0) (2024-09-28)
4
11
 
5
12
 
data/README.md CHANGED
@@ -15,9 +15,25 @@ And require the gem in your code.
15
15
  ```ruby
16
16
  require `jwt-aws-kms`
17
17
  ```
18
+ ## Supported algorithms
19
+
20
+ The gem supports the following AWS KMS algorithms:
21
+
22
+ | Algorithm Name | Description | JWA Name |
23
+ |----------------|--------------------------------------------------|-------------------------|
24
+ | RSASSA_PKCS1_V1_5_SHA_256 | RSASSA PKCS1 v1.5 using SHA-256 | RS256 |
25
+ | RSASSA_PKCS1_V1_5_SHA_384 | RSASSA PKCS1 v1.5 using SHA-384 | RS384 |
26
+ | RSASSA_PKCS1_V1_5_SHA_512 | RSASSA PKCS1 v1.5 using SHA-512 | RS512 |
27
+ | RSASSA_PSS_SHA_256 | RSASSA PSS using SHA-256 | PS256 |
28
+ | RSASSA_PSS_SHA_384 | RSASSA PSS using SHA-384 | PS384 |
29
+ | RSASSA_PSS_SHA_512 | RSASSA PSS using SHA-512 | PS512 |
30
+ | ECDSA_SHA_256 | ECDSA using P-256 and SHA-256 | ES256 |
31
+ | ECDSA_SHA_384 | ECDSA using P-384 and SHA-384 | ES384 |
32
+ | ECDSA_SHA_512 | ECDSA using P-521 and SHA-512 | ES512 |
18
33
 
19
34
  ## Usage
20
35
 
36
+ ### Basic usage
21
37
  ```ruby
22
38
 
23
39
  # Create a key, for example with the ruby AWS SDK
@@ -28,22 +44,15 @@ algo = ::JWT::Aws::KMS.for(algorithm: "HS512")
28
44
  token = JWT.encode(payload, key.key_metadata.key_id, algo)
29
45
  decoded_token = JWT.decode(token, key.key_metadata.key_id, true, algorithm: algo)
30
46
  ```
47
+ ### Replace default algorithms
31
48
 
32
- ## Supported algorithms
49
+ You can swap the default algorithms in the JWT gem to AWS backed ones by calling `::JWT::Aws::KMS.replace_defaults!`.
33
50
 
34
- The gem supports the following AWS KMS algorithms:
51
+ ```ruby
52
+ ::JWT::Aws::KMS.replace_defaults! # Called in a initializer of some kind
35
53
 
36
- | Algorithm Name | Description | JWA Name |
37
- |----------------|--------------------------------------------------|-------------------------|
38
- | RSASSA_PKCS1_V1_5_SHA_256 | RSASSA PKCS1 v1.5 using SHA-256 | RS256 |
39
- | RSASSA_PKCS1_V1_5_SHA_384 | RSASSA PKCS1 v1.5 using SHA-384 | RS384 |
40
- | RSASSA_PKCS1_V1_5_SHA_512 | RSASSA PKCS1 v1.5 using SHA-512 | RS512 |
41
- | RSASSA_PSS_SHA_256 | RSASSA PSS using SHA-256 | PS256 |
42
- | RSASSA_PSS_SHA_384 | RSASSA PSS using SHA-384 | PS384 |
43
- | RSASSA_PSS_SHA_512 | RSASSA PSS using SHA-512 | PS512 |
44
- | ECDSA_SHA_256 | ECDSA using P-256 and SHA-256 | ES256 |
45
- | ECDSA_SHA_384 | ECDSA using P-384 and SHA-384 | ES384 |
46
- | ECDSA_SHA_512 | ECDSA using P-521 and SHA-512 | ES512 |
54
+ token = JWT.encode(payload, "e25c502b-a383-44ac-a778-0d97e8688cb7", "HS512") # Encode payload with KMS key e25c502b-a383-44ac-a778-0d97e8688cb7
55
+ ```
47
56
 
48
57
  ## Development
49
58
 
@@ -3,7 +3,7 @@
3
3
  module JWT
4
4
  module Aws
5
5
  module KMS
6
- VERSION = "1.0.0"
6
+ VERSION = "1.1.0"
7
7
  end
8
8
  end
9
9
  end
data/lib/jwt/aws/kms.rb CHANGED
@@ -25,6 +25,14 @@ module JWT
25
25
  raise ArgumentError, "Algorithm #{algorithm} not supported"
26
26
  end.new(algorithm: algorithm)
27
27
  end
28
+
29
+ def self.replace_defaults!
30
+ [HmacKey, SignVerifyKey].each do |type|
31
+ type::MAPPINGS.each_key do |algorithm|
32
+ type.register_algorithm(type.new(algorithm: algorithm))
33
+ end
34
+ end
35
+ end
28
36
  end
29
37
  end
30
38
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: jwt-aws-kms
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Joakim Antman
@@ -66,7 +66,7 @@ metadata:
66
66
  allowed_push_host: https://rubygems.org
67
67
  homepage_uri: https://github.com/anakinj/jwt-aws-kms
68
68
  source_code_uri: https://github.com/anakinj/jwt-aws-kms
69
- changelog_uri: https://github.com/anakinj/jwt-aws-kms/blob/v1.0.0/CHANGELOG.md
69
+ changelog_uri: https://github.com/anakinj/jwt-aws-kms/blob/v1.1.0/CHANGELOG.md
70
70
  rubygems_mfa_required: 'true'
71
71
  post_install_message:
72
72
  rdoc_options: []