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

Better errors during Token Introspection in RS #3326

Open
2 tasks
mkurapov opened this issue Mar 4, 2025 · 0 comments
Open
2 tasks

Better errors during Token Introspection in RS #3326

mkurapov opened this issue Mar 4, 2025 · 0 comments
Assignees
Labels
pkg: auth Changes in the GNAP auth package. pkg: backend Changes in the backend package.

Comments

@mkurapov
Copy link
Contributor

mkurapov commented Mar 4, 2025

Context

Currently, when an Open Payments client tries to access a resource at the RS (resource server), for example getting an outgoing payment, the client does not know whether the token they've presented is simply inactive and needs to be rotated, or whether the token presented does not have the correct permissions to access the resource (insufficient grant/access).

This is because when the RS presenting the token to the AS, even if the token is active (not expired) the AS will end up returning an inactive token if the grant's access does not include the request's access:

for (const accessItem of access) {
const { access: grantAccess } = token.grant
const foundAccessItem = grantAccess.find((grantAccessItem) =>
compareRequestAndGrantAccessItems(
accessItem,
toOpenPaymentsAccess(grantAccessItem)
)
)
if (!foundAccessItem) {
return undefined

As a result, the RS's token introspection middleware will always return a Inactive Token error, even though that's not really the case (since the token is active, it's just the grant has incorrect permissions).

Desired behaviour

If an Open Payments client tries to access a resource at the RS and presents an active (non-expired) token but the token does not have the correct access as compared to the request's access, they should see an Insufficient Grant error.

Todo

  • In the AS, instead of returning an inactive token introspection response when the access matching up with the request wasn't found (foundAccessItem) , we should return an empty array in the access: { active: true, access: [], ...}
  • In the RS token introspection middleware, if the token introspection response includes an active token, but with an empty access list, the RS should return an Insufficient Grant 403 error
@mkurapov mkurapov added this to Rafiki Mar 4, 2025
@mkurapov mkurapov converted this from a draft issue Mar 4, 2025
@mkurapov mkurapov added pkg: backend Changes in the backend package. pkg: auth Changes in the GNAP auth package. labels Mar 4, 2025
@mkurapov mkurapov changed the title Better errors for token-introspection Better errors during Token Introspection in RS Mar 4, 2025
@mkurapov mkurapov moved this from Backlog to Todo in Rafiki Mar 4, 2025
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. pkg: backend Changes in the backend package.
Projects
Status: Todo
Development

No branches or pull requests

2 participants