Skip to content

Commit

Permalink
Resolve unexpected redirectUri parsing issue
Browse files Browse the repository at this point in the history
Altered the parsing method of redirectUri to correctly include requesterDidUrl.Host, which was previously fixed to the hostname "/iam/oid4vci/callback". Improved the error message on failed issuer DID ownership validation for better debugging and clarity.
  • Loading branch information
rolandgroen committed Apr 8, 2024
1 parent c79480e commit e132b29
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion auth/api/iam/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -646,7 +646,7 @@ func (r Wrapper) RequestOid4vciCredentialIssuance(ctx context.Context, request R
log.Logger().WithError(err).Errorf("failed convert did (%s) to url", requestHolder.String())
return nil, err
}
redirectUri, err := url.Parse("/iam/oid4vci/callback")
redirectUri, err := url.Parse(fmt.Sprintf("https://%s/iam/oid4vci/callback", requesterDidUrl.Host))
if err != nil {
log.Logger().WithError(err).Errorf("failed to create the url for host: %s", requesterDidUrl.Host)
return nil, err
Expand Down
4 changes: 2 additions & 2 deletions auth/api/iam/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -897,7 +897,7 @@ func TestWrapper_RequestOid4vciCredentialIssuance(t *testing.T) {
require.NoError(t, err)
require.NotNil(t, issuance)
actual := issuance.(RequestOid4vciCredentialIssuance200JSONResponse)
redirectUri, _ := url.Parse(actual.RedirectUri)
redirectUri, _ := url.Parse(actual.RedirectURI)
assert.Equal(t, "auth.server", redirectUri.Host)
assert.Equal(t, "/authorize", redirectUri.Path)
assert.True(t, redirectUri.Query().Has("state"))
Expand Down Expand Up @@ -926,7 +926,7 @@ func TestWrapper_RequestOid4vciCredentialIssuance(t *testing.T) {
ctx.vdr.EXPECT().IsOwner(nil, holderDID).Return(false, nil)
_, err := ctx.client.RequestOid4vciCredentialIssuance(nil, requestCredentials(holderDID, issuerDID, redirectURI))
require.Error(t, err)
assert.EqualError(t, err, "DID document not managed by this node")
assert.EqualError(t, err, "problem with owner DID: DID document not managed by this node")
})
t.Run("no_auth_endpoint_err_2", func(t *testing.T) {
ctx := newTestClient(t)
Expand Down

0 comments on commit e132b29

Please sign in to comment.