Skip to content

Commit

Permalink
feat: Support the ED25519 reference when pointing to the algorithm (#…
Browse files Browse the repository at this point in the history
…12)

* Backwards compatibility

* try action on ubuntu-22.04

* What about ubuntu-20.04

* Back to ubuntu-latest
  • Loading branch information
anakinj authored Aug 4, 2024
1 parent daaa740 commit 982ecf3
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 0 deletions.
1 change: 1 addition & 0 deletions lib/jwt/eddsa/algo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ module Algo
include JWT::JWA::SignatureAlgorithm

register_algorithm("EdDSA")
register_algorithm("ED25519")

class << self
def sign(_alg, msg, key)
Expand Down
8 changes: 8 additions & 0 deletions spec/integration_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,14 @@
end
end

context "when encoding with ED25519" do
it "executes successfully" do
token = JWT.encode(payload, private_key, "ED25519")
expect(JWT.decode(token, public_key, true, algorithm: "EdDSA"))
.to eq([payload, { "alg" => "EdDSA" }])
end
end

context "when decoding key is wrong" do
let(:public_key) { Ed25519::SigningKey.new("a" * 32).verify_key }
it "raises decoding error" do
Expand Down

0 comments on commit 982ecf3

Please sign in to comment.