From 10ed582a1efe5be8ac413aa861b018025ef46ea3 Mon Sep 17 00:00:00 2001 From: Pascal Knoth Date: Wed, 18 Dec 2024 12:00:56 +0100 Subject: [PATCH] take did controller as issuer for verifiable credentials --- lib/boruta/verifiable_credentials.ex | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/lib/boruta/verifiable_credentials.ex b/lib/boruta/verifiable_credentials.ex index 6aff14cd..b3e44c54 100644 --- a/lib/boruta/verifiable_credentials.ex +++ b/lib/boruta/verifiable_credentials.ex @@ -368,12 +368,18 @@ defmodule Boruta.VerifiableCredentials do now = :os.system_time(:seconds) sub = sub |> String.split("#") |> List.first() + iss = case client.did do + nil -> + Config.issuer() + did -> + did |> String.split("#") |> List.first() + end claims = %{ "sub" => sub, # TODO store credential "jti" => Config.issuer() <> "/credentials/#{credential_id}", - "iss" => client.did, + "iss" => iss, "nbf" => now, "iat" => now, "exp" => now + credential_configuration[:time_to_live], @@ -519,9 +525,16 @@ defmodule Boruta.VerifiableCredentials do :crypto.hash(:sha256, disclosure) |> Base.url_encode64(padding: false) end) + iss = case client.did do + nil -> + Config.issuer() + did -> + did |> String.split("#") |> List.first() + end + claims = %{ "sub" => sub, - "iss" => client.did || Config.issuer(), + "iss" => iss, "vct" => credential_configuration[:vct], "iat" => :os.system_time(:seconds), # TODO get exp from configuration