Skip to content

Commit daaa740

Browse files
authored
feat: Always set alg header to EdDSA (#13)
Define a static header no mater what the input is
1 parent a0f8200 commit daaa740

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

lib/jwt/eddsa/algo.rb

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,20 @@ module JWT
44
module EdDSA
55
# EdDSA algorithm implementation
66
module Algo
7-
include JWT::JWA::Algorithm
7+
include JWT::JWA::SignatureAlgorithm
88

99
register_algorithm("EdDSA")
1010

1111
class << self
12-
def sign(_algorithm, msg, key)
12+
def sign(_alg, msg, key)
1313
unless key.is_a?(Ed25519::SigningKey)
1414
raise_sign_error!("Key given is a #{key.class} but needs to be a Ed25519::SigningKey")
1515
end
1616

1717
key.sign(msg)
1818
end
1919

20-
def verify(_algorithm, public_key, signing_input, signature)
20+
def verify(_alg, public_key, signing_input, signature)
2121
unless public_key.is_a?(Ed25519::VerifyKey)
2222
raise_verify_error!("Key given is a #{public_key.class} but needs to be a Ed25519::VerifyKey")
2323
end
@@ -26,6 +26,10 @@ def verify(_algorithm, public_key, signing_input, signature)
2626
rescue Ed25519::VerifyError
2727
false
2828
end
29+
30+
def header(*)
31+
{ "alg" => "EdDSA" }
32+
end
2933
end
3034
end
3135
end

0 commit comments

Comments
 (0)