README.md in jwt-aws-kms-1.0.0 vs README.md in jwt-aws-kms-1.1.0
- old
+ new
@@ -13,38 +13,47 @@
And require the gem in your code.
```ruby
require `jwt-aws-kms`
```
+## Supported algorithms
+The gem supports the following AWS KMS algorithms:
+
+| Algorithm Name | Description | JWA Name |
+|----------------|--------------------------------------------------|-------------------------|
+| RSASSA_PKCS1_V1_5_SHA_256 | RSASSA PKCS1 v1.5 using SHA-256 | RS256 |
+| RSASSA_PKCS1_V1_5_SHA_384 | RSASSA PKCS1 v1.5 using SHA-384 | RS384 |
+| RSASSA_PKCS1_V1_5_SHA_512 | RSASSA PKCS1 v1.5 using SHA-512 | RS512 |
+| RSASSA_PSS_SHA_256 | RSASSA PSS using SHA-256 | PS256 |
+| RSASSA_PSS_SHA_384 | RSASSA PSS using SHA-384 | PS384 |
+| RSASSA_PSS_SHA_512 | RSASSA PSS using SHA-512 | PS512 |
+| ECDSA_SHA_256 | ECDSA using P-256 and SHA-256 | ES256 |
+| ECDSA_SHA_384 | ECDSA using P-384 and SHA-384 | ES384 |
+| ECDSA_SHA_512 | ECDSA using P-521 and SHA-512 | ES512 |
+
## Usage
+### Basic usage
```ruby
# Create a key, for example with the ruby AWS SDK
key = Aws::KMS::Client.new.create_key(key_spec: "HMAC_512", key_usage: "GENERATE_VERIFY_MAC")
algo = ::JWT::Aws::KMS.for(algorithm: "HS512")
token = JWT.encode(payload, key.key_metadata.key_id, algo)
decoded_token = JWT.decode(token, key.key_metadata.key_id, true, algorithm: algo)
```
+### Replace default algorithms
-## Supported algorithms
+You can swap the default algorithms in the JWT gem to AWS backed ones by calling `::JWT::Aws::KMS.replace_defaults!`.
-The gem supports the following AWS KMS algorithms:
+```ruby
+::JWT::Aws::KMS.replace_defaults! # Called in a initializer of some kind
-| Algorithm Name | Description | JWA Name |
-|----------------|--------------------------------------------------|-------------------------|
-| RSASSA_PKCS1_V1_5_SHA_256 | RSASSA PKCS1 v1.5 using SHA-256 | RS256 |
-| RSASSA_PKCS1_V1_5_SHA_384 | RSASSA PKCS1 v1.5 using SHA-384 | RS384 |
-| RSASSA_PKCS1_V1_5_SHA_512 | RSASSA PKCS1 v1.5 using SHA-512 | RS512 |
-| RSASSA_PSS_SHA_256 | RSASSA PSS using SHA-256 | PS256 |
-| RSASSA_PSS_SHA_384 | RSASSA PSS using SHA-384 | PS384 |
-| RSASSA_PSS_SHA_512 | RSASSA PSS using SHA-512 | PS512 |
-| ECDSA_SHA_256 | ECDSA using P-256 and SHA-256 | ES256 |
-| ECDSA_SHA_384 | ECDSA using P-384 and SHA-384 | ES384 |
-| ECDSA_SHA_512 | ECDSA using P-521 and SHA-512 | ES512 |
+token = JWT.encode(payload, "e25c502b-a383-44ac-a778-0d97e8688cb7", "HS512") # Encode payload with KMS key e25c502b-a383-44ac-a778-0d97e8688cb7
+```
## Development
[Localstack](https://www.localstack.cloud/) can be used to simulate the AWS KMS environment.