JWT: updated to make JWT algorithm support more flexible, and simple to extend with specific algorithm.

This commit is contained in:
2018-10-17 10:59:57 +02:00
parent f97f59b703
commit 0baa05cf63
10 changed files with 340 additions and 84 deletions

View File

@@ -64,14 +64,16 @@ feature -- Conversion
encoded_string (a_secret: READABLE_STRING_8): STRING
local
alg, sign: READABLE_STRING_8
sign, alg_name: READABLE_STRING_8
alg: JWT_ALG
l_enc_payload, l_enc_header: READABLE_STRING_8
do
reset_error
alg := header.algorithm
if not is_supporting_signature_algorithm (alg) then
report_unsupported_alg_error (alg)
alg := alg_hs256 -- Default ...
alg_name := header.algorithm
alg := algorithms [alg_name]
if alg = Void then
report_unsupported_alg_error (alg_name)
alg := algorithms.hs256 -- Default ...
end
l_enc_header := base64url_encode (header.string)
l_enc_payload := base64url_encode (claimset.string)
@@ -94,12 +96,12 @@ feature -- Element change
set_algorithm_to_hs256
do
set_algorithm (alg_hs256)
set_algorithm (algorithms.hs256.name)
end
set_algorithm_to_none
do
set_algorithm (alg_none)
set_algorithm (algorithms.none.name)
end
end