Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(auth): use gnap error middleware on idp api #3094

Merged
merged 4 commits into from
Mar 7, 2025

Conversation

njlie
Copy link
Contributor

@njlie njlie commented Nov 8, 2024

Changes proposed in this pull request

  • Adds the gnapServerErrorMiddleware to the routes on the Identity Provider API on the auth server.

Context

Closes #3029.

This ended up being a one-line change, as the IDP responses were added already in the spec from #850 and #3024. The code already throws these errors and had tests added as of #2400. There was one potential response missing from the spec, however.

Checklist

  • Related issues linked using fixes #number
  • Tests added/updated
  • Make sure that all checks pass
  • Bruno collection updated (if necessary)
  • Documentation issue created with user-docs label (if necessary)
  • OpenAPI specs updated (if necessary)

@github-actions github-actions bot added type: source Changes business logic pkg: auth Changes in the GNAP auth package. labels Nov 8, 2024
Copy link

netlify bot commented Nov 8, 2024

Deploy Preview for brilliant-pasca-3e80ec canceled.

Name Link
🔨 Latest commit f16ee81
🔍 Latest deploy log https://app.netlify.com/sites/brilliant-pasca-3e80ec/deploys/67ca21e574eca500089db431

oana-lolea
oana-lolea previously approved these changes Nov 11, 2024
Comment on lines +42 to +47
'500':
description: Internal Server Error
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Would it be good to provide the actual GNAP response error objects in the IDP spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll add them since it's a pretty bare PR as it is right now

mkurapov
mkurapov previously approved these changes Nov 12, 2024
Copy link
Contributor

@mkurapov mkurapov left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can make my comment into a separate issue, if you'd like

@njlie njlie dismissed stale reviews from mkurapov and oana-lolea via 1735c6e November 12, 2024 19:21
@njlie njlie requested review from oana-lolea and mkurapov November 12, 2024 20:45
oana-lolea
oana-lolea previously approved these changes Nov 13, 2024
@njlie njlie force-pushed the nl/3029/auth-interaction-errors branch from 1735c6e to 0282619 Compare November 13, 2024 17:32
@njlie njlie requested a review from oana-lolea November 13, 2024 17:32
content:
application/json:
schema:
$ref: '#/components/schemas/gnap-error'
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I figured it might make sense to include this in the auth server spec as well for Open Payments, so I captured it in an issue here.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Makes sense! if you want, we could probably merge the open payments issue first, bump the client, and import the yaml files in here so we can reference them as ./auth-server.yaml#/components/schemas/..., what do you think? Unless we want to decouple the IDP spec from the auth server spec?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's bump the OP client for this 👍

oana-lolea
oana-lolea previously approved these changes Nov 14, 2024
@mkurapov mkurapov added the do not merge Do not merge PRs with these label label Nov 26, 2024
@njlie njlie force-pushed the nl/3029/auth-interaction-errors branch from 0282619 to 172f556 Compare March 3, 2025 21:26
@mkurapov mkurapov removed the do not merge Do not merge PRs with these label label Mar 4, 2025
@njlie njlie force-pushed the nl/3029/auth-interaction-errors branch from fa5e15f to b97e94d Compare March 5, 2025 17:23
@@ -165,11 +193,23 @@ paths:
description: Accepted
'400':
description: Not Found
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
description: Not Found
description: Bad Request

content:
application/json:
schema:
$ref: '#/components/schemas/error-invalid-interaction'
'401':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think also we have the user_denied invalid_request possible in this route

@@ -39,6 +39,16 @@ paths:
description: Interaction id
'401':
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be 400?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have request_denied in this flow possible

Copy link
Contributor Author

@njlie njlie Mar 6, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We also have request_denied in this flow possible

We shoud have request_denied in https://github.com/interledger/rafiki/pull/3094/files#diff-196f8d522cc447a08b51f0cf830f0c27ebc33e85c7cd936d96d1d6d053a1a754R46-R51

Should this be 400?

The conditional for throwing this response can be satisfied by not finding the interaction based on the provided nonce + id, not being in the pending state, or the associated grant being revoked. I felt as though these cases sufficiently fell under "incorrect credentials".

Looking at it now, I think we could break up the conditional into 400 (or 404) for the case where it can't find the interaction because the id or the nonce doesn't match up, and 403 for when the grant is revoked or the interaction isn't in a pending state

@github-actions github-actions bot added the type: tests Testing related label Mar 6, 2025
@njlie njlie requested review from mkurapov and oana-lolea March 6, 2025 22:33
@njlie njlie merged commit 3d40648 into main Mar 7, 2025
43 checks passed
@njlie njlie deleted the nl/3029/auth-interaction-errors branch March 7, 2025 17:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pkg: auth Changes in the GNAP auth package. type: source Changes business logic type: tests Testing related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Properly return errors in Auth Interaction server
3 participants