Skip to content

Commit

Permalink
take did controller as issuer for verifiable credentials
Browse files Browse the repository at this point in the history
  • Loading branch information
patatoid committed Dec 18, 2024
1 parent beb167f commit 10ed582
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions lib/boruta/verifiable_credentials.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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],
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 10ed582

Please sign in to comment.