Skip to content

Commit

Permalink
Handle direct_post return from wallet to verifier (#2702)
Browse files Browse the repository at this point in the history
* added authorize endpoint as specified by rfc6549 authorization code (#2626)
* add e2e test
  • Loading branch information
woutslakhorst authored Jan 22, 2024
1 parent 04c5eb7 commit f642fec
Show file tree
Hide file tree
Showing 32 changed files with 1,535 additions and 265 deletions.
9 changes: 3 additions & 6 deletions auth/api/iam/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,11 +139,8 @@ func (r Wrapper) HandleTokenRequest(ctx context.Context, request HandleTokenRequ
case "authorization_code":
// Options:
// - OpenID4VCI
// - OpenID4VP, vp_token is sent in Token Response
return nil, oauth.OAuth2Error{
Code: oauth.UnsupportedGrantType,
Description: "not implemented yet",
}
// - OpenID4VP
return r.handleAccessTokenRequest(ctx, *ownDID, request.Body.Code, request.Body.RedirectUri, request.Body.ClientId)
case "urn:ietf:params:oauth:grant-type:pre-authorized_code":
// Options:
// - OpenID4VCI
Expand Down Expand Up @@ -399,7 +396,7 @@ func (r Wrapper) RequestAccessToken(ctx context.Context, request RequestAccessTo
return nil, err
}
if !isWallet {
return nil, core.InvalidInputError("did not owned by this node: %w", err)
return nil, core.InvalidInputError("did not owned by this node")
}
if request.Body.UserID != nil && len(*request.Body.UserID) > 0 {
// forward to user flow
Expand Down
2 changes: 1 addition & 1 deletion auth/api/iam/api_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,7 @@ func TestWrapper_HandleAuthorizeRequest(t *testing.T) {
ctx.vdr.EXPECT().IsOwner(gomock.Any(), holderDID).Return(true, nil)
ctx.holderRole.EXPECT().ClientMetadata(gomock.Any(), "https://example.com/.well-known/authorization-server/iam/verifier").Return(&clientMetadata, nil)
ctx.holderRole.EXPECT().PresentationDefinition(gomock.Any(), "https://example.com/iam/verifier/presentation_definition?scope=test").Return(&pe.PresentationDefinition{}, nil)
ctx.holderRole.EXPECT().BuildPresentation(gomock.Any(), holderDID, pe.PresentationDefinition{}, clientMetadata.VPFormats, "nonce").Return(&vc.VerifiablePresentation{}, &pe.PresentationSubmission{}, nil)
ctx.holderRole.EXPECT().BuildPresentation(gomock.Any(), holderDID, pe.PresentationDefinition{}, clientMetadata.VPFormats, "nonce", verifierDID.URI()).Return(&vc.VerifiablePresentation{}, &pe.PresentationSubmission{}, nil)
ctx.holderRole.EXPECT().PostAuthorizationResponse(gomock.Any(), vc.VerifiablePresentation{}, pe.PresentationSubmission{}, "https://example.com/iam/verifier/response", "state").Return("https://example.com/iam/holder/redirect", nil)

res, err := ctx.client.HandleAuthorizeRequest(requestContext(map[string]string{
Expand Down
99 changes: 99 additions & 0 deletions auth/api/iam/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit f642fec

Please sign in to comment.