-
Notifications
You must be signed in to change notification settings - Fork 75
feat:API for verify authorization response#1561
Conversation
📝 WalkthroughWalkthroughAdds an OID4VP authorization-response verification flow: new DTO and HTTP endpoint in API Gateway, message routing through OID4VC verification service and NATS, a new agent-service controller/service handler, plus common constants and agent URL mapping. Changes
Sequence DiagramsequenceDiagram
participant Client as API Client
participant Gateway as API Gateway
participant OID4vcSvc as OID4VC Service
participant NATS as NATS Broker
participant AgentSvc as Agent Service
participant AgentAPI as Agent HTTP Endpoint
Client->>Gateway: POST /orgs/:orgId/oid4vp/verify-authorization-response\n(VerifyAuthorizationResponseDto)
Gateway->>Gateway: Validate DTO
Gateway->>OID4vcSvc: verifyAuthorizationResponse(payload, orgId)
OID4vcSvc->>OID4vcSvc: Lookup agentEndPoint for orgId
OID4vcSvc->>OID4vcSvc: Build agent URL (getAgentUrl + constant)
OID4vcSvc->>NATS: Publish "agent-verify-oid4vp-session-auth-response"\n{ url, orgId, verifyAuthorizationResponse }
NATS->>AgentSvc: Deliver message
AgentSvc->>AgentSvc: Get org API key
AgentSvc->>AgentAPI: POST to agent URL with authorizationResponse (API key)
AgentAPI-->>AgentSvc: Return verification result
AgentSvc-->>NATS: Reply result
NATS-->>OID4vcSvc: Deliver result
OID4vcSvc-->>Gateway: Return result
Gateway-->>Client: 201 CREATED (result)
Estimated Code Review Effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Suggested Labels
Suggested Reviewers
Poem
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 6
🤖 Fix all issues with AI agents
In
`@apps/api-gateway/src/oid4vc-verification/dtos/verify-authorization-response.dto.ts`:
- Around line 29-34: The optional origin field in the
VerifyAuthorizationResponseDto is decorated with `@IsString`() but missing
`@IsOptional`(), causing validation to fail when origin is omitted; update the
origin property by adding `@IsOptional`() immediately above `@IsString`() (i.e.,
annotate the origin field in VerifyAuthorizationResponseDto with `@IsOptional`()
then `@IsString`()) so class-validator allows requests that don't include origin.
In `@apps/api-gateway/src/oid4vc-verification/oid4vc-verification.controller.ts`:
- Line 723: The POST route decorator currently defined as
`@Post`('/orgs/:orgId/verify-authorization-response') in
oid4vc-verification.controller.ts should be renamed to
`@Post`('/orgs/:orgId/oid4vp/verify-authorization-response') so it matches the
existing OID4VP endpoint prefix; update the route string on the same controller
method (the method handling the authorization response) and adjust any tests or
internal references that call the old path to the new
'/orgs/:orgId/oid4vp/verify-authorization-response' URL.
- Around line 758-763: Change the verification endpoint to return HTTP 200 OK
and use the shared message constant instead of a hardcoded string: replace
HttpStatus.CREATED with HttpStatus.OK in the finalResponse object and the
res.status(...) call, and swap the 'Authorization response verified
successfully' literal for the appropriate ResponseMessages constant (use the
same ResponseMessages pattern used by other endpoints). Ensure the variable
finalResponse and the response returned by res.status(...) are updated
accordingly.
In `@apps/api-gateway/src/oid4vc-verification/oid4vc-verification.service.ts`:
- Around line 184-186: The debug log in verifyAuthorizationResponse currently
serializes the full verifyAuthorizationResponse (risking leaking id_token and
other sensitive fields); change the logger.debug call in
oid4vc-verification.service (the verifyAuthorizationResponse handler) to omit
the full payload and log only non-sensitive identifiers such as
verifyAuthorizationResponse.verificationSessionId (keep orgId and user?.id),
removing JSON.stringify(verifyAuthorizationResponse) and any other full-object
prints.
In `@apps/oid4vc-verification/src/oid4vc-verification.controller.ts`:
- Around line 183-194: Change the handler to avoid logging the full
VerifyAuthorizationResponse and to use the same parameter name as other
handlers: rename the destructured `user` parameter to `userDetails` (to avoid
shadowing the `user` type) and in the logger.debug call remove
JSON.stringify(verifyAuthorizationResponse) — log only safe identifiers such as
`verificationSessionId` (from the VerifyAuthorizationResponse) plus `orgId` and
`userDetails.id`; then pass `verifyAuthorizationResponse` and `userDetails`
unchanged into `oid4vpVerificationService.verifyAuthorizationResponse`.
In `@apps/oid4vc-verification/src/oid4vc-verification.service.ts`:
- Around line 692-721: In verifyAuthorizationResponse, avoid logging full
payloads: stop JSON.stringifying verifyAuthorizationResponse and
verificationResult; instead extract and log a non-sensitive identifier (e.g.,
verificationSessionId or a correlation id) from the verifyAuthorizationResponse
object and log only that plus minimal outcome info (e.g.,
verificationResult.status or a success/failure flag). Update the logger.debug
calls in verifyAuthorizationResponse to reference the identifier variable (not
the whole object) and to redact or summarize verificationResult before logging
to prevent sensitive tokens/credentials from being written to logs.
🧹 Nitpick comments (3)
apps/api-gateway/src/oid4vc-verification/dtos/verify-authorization-response.dto.ts (1)
1-35: Consider adding@IsUrl()or a URL validation decorator fororigin.Since
originrepresents a URL origin (e.g.,https://example.com), a bare@IsString()allows any arbitrary string. Consider@IsUrl()or a custom validator if stricter validation is desired.apps/agent-service/src/interface/agent-service.interface.ts (1)
663-668: DuplicateVerifyAuthorizationResponseinterface — also defined inoid4vp-verification-sessions.interfaces.ts.This exact interface is duplicated at
apps/oid4vc-verification/interfaces/oid4vp-verification-sessions.interfaces.ts:26-30. Consider extracting it to a shared location (e.g.,libs/common/src/interfaces/) to avoid drift.apps/agent-service/src/agent-service.service.ts (1)
2288-2309: Implementation follows existing patterns; consider extracting the shared interface.The method is clean and consistent with peer methods like
createOid4vpVerificationSession. No functional concerns.One note:
VerifyAuthorizationResponseis defined identically in bothapps/agent-service/src/interface/agent-service.interface.ts(Lines 663–667) andapps/oid4vc-verification/interfaces/oid4vp-verification-sessions.interfaces.ts(Lines 25–29). Consider extracting this into a shared module (e.g.,@credebl/common/interfaces) to avoid drift between the two copies.,
apps/api-gateway/src/oid4vc-verification/dtos/verify-authorization-response.dto.ts
Show resolved
Hide resolved
apps/api-gateway/src/oid4vc-verification/oid4vc-verification.controller.ts
Outdated
Show resolved
Hide resolved
apps/api-gateway/src/oid4vc-verification/oid4vc-verification.controller.ts
Show resolved
Hide resolved
apps/api-gateway/src/oid4vc-verification/oid4vc-verification.service.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In `@apps/api-gateway/src/oid4vc-verification/oid4vc-verification.controller.ts`:
- Line 749: The debug log in the verifyAuthorizationResponse flow contains a
typo: the template literal in the logger.debug call within the method
verifyAuthorizationResponse (or the Oid4vcVerificationController) has an extra
closing brace `orgId=${orgId}}`; remove the stray `}` so it reads
`orgId=${orgId}` to fix the malformed log output.
🧹 Nitpick comments (3)
apps/api-gateway/src/oid4vc-verification/dtos/verify-authorization-response.dto.ts (1)
9-11: Consider adding@IsUUID()validation forverificationSessionId.The example value is a UUID and other endpoints in this controller consistently validate UUID parameters with
ParseUUIDPipe. Using@IsUUID()here would catch malformed IDs at the DTO validation layer rather than letting them propagate to the agent service.Proposed fix
+import { IsNotEmpty, IsObject, IsOptional, IsString, IsUUID } from 'class-validator'; -import { IsNotEmpty, IsObject, IsOptional, IsString } from 'class-validator';`@IsString`() + `@IsUUID`() `@IsNotEmpty`() verificationSessionId!: string;apps/oid4vc-verification/src/oid4vc-verification.service.ts (2)
697-699: UnnecessaryJSON.stringifyon a plain string value.
verificationSessionIdis already astring, so wrapping it inJSON.stringifyjust adds quotes around it in the log output. Use it directly.Proposed fix
this.logger.debug( - `[verifyAuthorizationResponse] called for orgId=${orgId}, verificationSessionId=${JSON.stringify(verifyAuthorizationResponse.verificationSessionId)}` + `[verifyAuthorizationResponse] called for orgId=${orgId}, verificationSessionId=${verifyAuthorizationResponse.verificationSessionId}` );
705-705: Unusedidfrom destructuring.
idis destructured fromagentDetailsbut never referenced. OnlyagentEndPointis used.Proposed fix
- const { agentEndPoint, id } = agentDetails; + const { agentEndPoint } = agentDetails;
apps/api-gateway/src/oid4vc-verification/oid4vc-verification.controller.ts
Outdated
Show resolved
Hide resolved
Signed-off-by: shitrerohit <rohit.shitre@ayanworks.com>
Signed-off-by: shitrerohit <rohit.shitre@ayanworks.com>
Signed-off-by: shitrerohit <rohit.shitre@ayanworks.com>
0b5e177 to
262fc2b
Compare
Quality Gate Passed Quality Gate passed
Issues
1 New issue
0 Accepted issues
Measures
0 Security Hotspots
0.0% Coverage on New Code
0.0% Duplication on New Code
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
🤖 Fix all issues with AI agents
In
`@apps/api-gateway/src/oid4vc-verification/dtos/verify-authorization-response.dto.ts`:
- Around line 16-23: Replace the real-looking example JWT in the Swagger example
payload with a clearly fake placeholder to avoid secret-detection false
positives: locate the example object in verify-authorization-response.dto.ts
(the example -> id_token -> Passport value) and change the token string to an
obvious placeholder like 'eyJ...example-token...' or 'REDACTED_EXAMPLE_TOKEN' so
the docs remain illustrative but won’t trigger Gitleaks.
🧹 Nitpick comments (1)
apps/oid4vc-verification/interfaces/oid4vp-verification-sessions.interfaces.ts (1)
27-31: DuplicateVerifyAuthorizationResponseinterface across service boundaries.This interface is identically defined in
apps/agent-service/src/interface/agent-service.interface.ts(lines 663–667). Consider extracting it into a shared library (e.g.,libs/common) to avoid drift between the two definitions.#!/bin/bash # Check if there are other duplicate interface patterns across these two directories rg -n "VerifyAuthorizationResponse" --type=ts
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Example JWT in Swagger docs triggers secret-detection (Gitleaks).
The example JWT on line 20 is flagged by Gitleaks as a potential secret. While it's clearly a dummy value for documentation, consider using a visibly fake placeholder (e.g., 'eyJ...example-token...') to suppress the false positive and avoid noise in CI secret scans.
🧰 Tools
🪛 ESLint
[error] 19-19: There should be no linebreak after '['.
(array-bracket-newline)
[error] 21-21: There should be no linebreak before ']'.
(array-bracket-newline)
🪛 Gitleaks (8.30.0)
[high] 20-20: Uncovered a JSON Web Token, which may lead to unauthorized access to web applications and sensitive user data.
(jwt)
🤖 Prompt for AI Agents
In
`@apps/api-gateway/src/oid4vc-verification/dtos/verify-authorization-response.dto.ts`
around lines 16 - 23, Replace the real-looking example JWT in the Swagger
example payload with a clearly fake placeholder to avoid secret-detection false
positives: locate the example object in verify-authorization-response.dto.ts
(the example -> id_token -> Passport value) and change the token string to an
obvious placeholder like 'eyJ...example-token...' or 'REDACTED_EXAMPLE_TOKEN' so
the docs remain illustrative but won’t trigger Gitleaks.
Uh oh!
There was an error while loading. Please reload this page.
What?
API for verify authorization response
How?
Added support for verifying OpenID4VC DCQL proof requests through a new verification endpoint.
Added a new agent call to verify the authorization response.
Summary by CodeRabbit