Skip to content

Commit

Permalink
fix kb-jwt payload if value is null (#166)
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Tuerk <[email protected]>
  • Loading branch information
JoTiTu authored Aug 19, 2024
1 parent 414fe75 commit 84031a1
Showing 1 changed file with 10 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,19 @@ public async Task<string> GenerateKbProofOfPossessionAsync(KeyId keyId, string a
}
}

var payload = new
var payload = new Dictionary<string, object>
{
aud = audience,
nonce,
iat = DateTimeOffset.UtcNow.ToUnixTimeSeconds(),
sd_hash = sdHash,
iss = clientId
{ "aud", audience },
{ "nonce", nonce },
{ "iat" , DateTimeOffset.UtcNow.ToUnixTimeSeconds() }
};

if (!sdHash.IsNullOrEmpty())
payload["sd_hash"] = sdHash!;

if (!clientId.IsNullOrEmpty())
payload["iss"] = clientId!;

return await CreateSignedJwt(header, payload, keyId);
}

Expand Down

0 comments on commit 84031a1

Please sign in to comment.