mirror of
https://github.com/processone/ejabberd.git
synced 2024-12-22 17:28:25 +01:00
Derive the alg field of the JWS object using a erlang-jose library function rather than hardcoding
This commit is contained in:
parent
4fc3d511ce
commit
133d2ae6d5
@ -252,14 +252,16 @@ sign_json_jose(Key, Json, Nonce) ->
|
||||
{_, BinaryPubKey} = jose_jwk:to_binary(PubKey),
|
||||
% ?INFO_MSG("Key Record: ~p", [jose_jwk:to_map(Key)]),
|
||||
PubKeyJson = jiffy:decode(BinaryPubKey),
|
||||
% Jws object containing the algorithm
|
||||
%% TODO: Dont hardcode the alg
|
||||
JwsObj = jose_jws:from(
|
||||
#{ <<"alg">> => <<"ES256">>
|
||||
%% TODO: Ensure this works for all cases
|
||||
AlgMap = jose_jwk:signer(Key),
|
||||
% ?INFO_MSG("Algorithm:~p~n", [AlgMap]),
|
||||
JwsMap =
|
||||
#{ <<"jwk">> => PubKeyJson
|
||||
% , <<"b64">> => true
|
||||
, <<"jwk">> => PubKeyJson
|
||||
, <<"nonce">> => list_to_bitstring(Nonce)
|
||||
}),
|
||||
},
|
||||
JwsObj0 = maps:merge(JwsMap, AlgMap),
|
||||
JwsObj = jose_jws:from(JwsObj0),
|
||||
%% Signed Message
|
||||
jose_jws:sign(Key, Json, JwsObj).
|
||||
|
||||
@ -388,7 +390,7 @@ generate_key() ->
|
||||
%% Just a test
|
||||
scenario0(KeyFile) ->
|
||||
PrivateKey = jose_jwk:from_file(KeyFile),
|
||||
% scenario("http://localhost:4000", "2", PrivateKey).
|
||||
new_user_scenario("http://localhost:4000").
|
||||
scenario("http://localhost:4000", "2", PrivateKey).
|
||||
% new_user_scenario("http://localhost:4000").
|
||||
|
||||
% ejabberd_acme:scenario0("/home/konstantinos/Desktop/Programming/ejabberd/private_key_temporary").
|
||||
|
Loading…
Reference in New Issue
Block a user