Skip to content

Commit

Permalink
Merge pull request #1729 from aholovko/fix_response_uri_oid4vp_id2
Browse files Browse the repository at this point in the history
fix: response_uri for oid4vp id2
  • Loading branch information
fqutishat authored Jun 10, 2024
2 parents b2df12a + 9711611 commit 3c62d32
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
2 changes: 1 addition & 1 deletion cmd/vc-rest/startcmd/start.go
Original file line number Diff line number Diff line change
Expand Up @@ -955,7 +955,7 @@ func buildEchoHandler(
ProfileService: verifierProfileSvc,
PresentationVerifier: verifyPresentationSvc,
TrustRegistry: trustRegistryService,
RedirectURL: conf.StartupParameters.apiGatewayURL + oidc4VPCheckEndpoint,
ResponseURI: conf.StartupParameters.apiGatewayURL + oidc4VPCheckEndpoint,
TokenLifetime: 15 * time.Minute,
Metrics: metrics,
})
Expand Down
2 changes: 1 addition & 1 deletion component/wallet-cli/pkg/oidc4vp/models.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,10 @@ type RequestObject struct {
IAT int64 `json:"iat"`
ResponseType string `json:"response_type"`
ResponseMode string `json:"response_mode"`
ResponseURI string `json:"response_uri"`
Scope string `json:"scope"`
Nonce string `json:"nonce"`
ClientID string `json:"client_id"`
RedirectURI string `json:"redirect_uri"`
State string `json:"state"`
Exp int64 `json:"exp"`
ClientMetadata *ClientMetadata `json:"client_metadata"`
Expand Down
10 changes: 5 additions & 5 deletions component/wallet-cli/pkg/oidc4vp/oidc4vp_flow.go
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ func (f *Flow) sendAuthorizationResponse(
attestationRequired bool,
) error {
slog.Info("Sending authorization response",
"redirect_uri", requestObject.RedirectURI,
"response_uri", requestObject.ResponseURI,
)

start := time.Now()
Expand Down Expand Up @@ -450,7 +450,7 @@ func (f *Flow) sendAuthorizationResponse(

f.perfInfo.CreateAuthorizedResponse = time.Since(start)

return f.postAuthorizationResponse(ctx, requestObject.RedirectURI, []byte(v.Encode()))
return f.postAuthorizationResponse(ctx, requestObject.ResponseURI, []byte(v.Encode()))
}

func (f *Flow) createVPToken(
Expand Down Expand Up @@ -683,17 +683,17 @@ func extractCustomScopeClaims(requestObjectScope string) (map[string]Claims, err
return claimsData, nil
}

func (f *Flow) postAuthorizationResponse(ctx context.Context, redirectURI string, body []byte) error {
func (f *Flow) postAuthorizationResponse(ctx context.Context, responseURI string, body []byte) error {
slog.Info("Sending authorization response",
"redirect_uri", redirectURI,
"response_uri", responseURI,
)

start := time.Now()
defer func() {
f.perfInfo.SendAuthorizedResponse = time.Since(start)
}()

req, err := http.NewRequestWithContext(ctx, http.MethodPost, redirectURI, bytes.NewBuffer(body))
req, err := http.NewRequestWithContext(ctx, http.MethodPost, responseURI, bytes.NewBuffer(body))
if err != nil {
return fmt.Errorf("new authorization response request: %w", err)
}
Expand Down
2 changes: 1 addition & 1 deletion pkg/service/oidc4vp/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,12 +110,12 @@ type RequestObject struct {
ISS string `json:"iss"`
ResponseType string `json:"response_type"`
ResponseMode string `json:"response_mode"`
ResponseURI string `json:"response_uri"`
Scope string `json:"scope"`
Nonce string `json:"nonce"`
ClientID string `json:"client_id"`
ClientIDScheme string `json:"client_id_scheme"`
RedirectURI string `json:"redirect_uri"`
ResponseURI string `json:"response_uri"`
State string `json:"state"`
Exp int64 `json:"exp"`
// Deprecated: Use client_metadata instead.
Expand Down
9 changes: 5 additions & 4 deletions pkg/service/oidc4vp/oidc4vp_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ type Config struct {
PresentationVerifier presentationVerifier
VDR vdrapi.Registry
TrustRegistry trustRegistry
RedirectURL string
ResponseURI string
TokenLifetime time.Duration
Metrics metricsProvider
}
Expand All @@ -143,7 +143,7 @@ type Service struct {
vdr vdrapi.Registry
trustRegistry trustRegistry

redirectURL string
responseURI string
tokenLifetime time.Duration

metrics metricsProvider
Expand All @@ -165,7 +165,7 @@ func NewService(cfg *Config) *Service {
documentLoader: cfg.DocumentLoader,
profileService: cfg.ProfileService,
presentationVerifier: cfg.PresentationVerifier,
redirectURL: cfg.RedirectURL,
responseURI: cfg.ResponseURI,
tokenLifetime: cfg.TokenLifetime,
vdr: cfg.VDR,
trustRegistry: cfg.TrustRegistry,
Expand Down Expand Up @@ -836,11 +836,12 @@ func (s *Service) createRequestObject(
ISS: profile.SigningDID.DID,
ResponseType: vpTokenIDTokenResponseType,
ResponseMode: directPostResponseMode,
ResponseURI: s.responseURI,
Scope: getScope(customScopes),
Nonce: nonce,
ClientID: profile.SigningDID.DID,
ClientIDScheme: didClientIDScheme,
RedirectURI: s.redirectURL,
RedirectURI: s.responseURI,
State: string(tx.ID),
Exp: now.Add(tokenLifetime).Unix(),
Registration: RequestObjectRegistration{
Expand Down
8 changes: 4 additions & 4 deletions pkg/service/oidc4vp/oidc4vp_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ func TestService_InitiateOidcInteraction(t *testing.T) {
TransactionManager: txManager,
RequestObjectStore: requestObjectStore,
KMSRegistry: kmsRegistry,
RedirectURL: "test://redirect",
ResponseURI: "test://response",
TokenLifetime: time.Second * 100,
})

Expand Down Expand Up @@ -171,7 +171,7 @@ func TestService_InitiateOidcInteraction(t *testing.T) {
TransactionManager: txManagerErr,
RequestObjectStore: requestObjectStore,
KMSRegistry: kmsRegistry,
RedirectURL: "test://redirect",
ResponseURI: "test://response",
})

info, err := withError.InitiateOidcInteraction(
Expand All @@ -197,7 +197,7 @@ func TestService_InitiateOidcInteraction(t *testing.T) {
TransactionManager: txManager,
RequestObjectStore: requestObjectStoreErr,
KMSRegistry: kmsRegistry,
RedirectURL: "test://redirect",
ResponseURI: "test://response",
})

info, err := withError.InitiateOidcInteraction(
Expand All @@ -222,7 +222,7 @@ func TestService_InitiateOidcInteraction(t *testing.T) {
TransactionManager: txManager,
RequestObjectStore: requestObjectStore,
KMSRegistry: kmsRegistry,
RedirectURL: "test://redirect",
ResponseURI: "test://response",
})

info, err := withError.InitiateOidcInteraction(
Expand Down

0 comments on commit 3c62d32

Please sign in to comment.