mirror of
https://github.com/logto-io/logto.git
synced 2025-03-10 22:22:45 -05:00
fix(core): set oidc access denied error code to 403 (#5725)
This commit is contained in:
parent
d48094be27
commit
d545303568
3 changed files with 14 additions and 3 deletions
7
.changeset/forty-grapes-relax.md
Normal file
7
.changeset/forty-grapes-relax.md
Normal file
|
@ -0,0 +1,7 @@
|
|||
---
|
||||
'@logto/core': patch
|
||||
---
|
||||
|
||||
Fix OIDC AccessDenied error code to 403.
|
||||
|
||||
This error may happen when you try to grant an access token to a user lacking the required permissions, especially when granting for orgnization related resources. The error code should be 403 instead of 400.
|
|
@ -229,7 +229,9 @@ export const buildHandler: (
|
|||
if (organizationId) {
|
||||
// Check membership
|
||||
if (!(await queries.organizations.relations.users.exists(organizationId, account.accountId))) {
|
||||
throw new AccessDenied('user is not a member of the organization');
|
||||
const error = new AccessDenied('user is not a member of the organization');
|
||||
error.statusCode = 403;
|
||||
throw error;
|
||||
}
|
||||
|
||||
// Check if the organization is granted (third-party application only) by the user
|
||||
|
@ -242,7 +244,9 @@ export const buildHandler: (
|
|||
organizationId
|
||||
))
|
||||
) {
|
||||
throw new AccessDenied('organization access is not granted to the application');
|
||||
const error = new AccessDenied('organization access is not granted to the application');
|
||||
error.statusCode = 403;
|
||||
throw error;
|
||||
}
|
||||
}
|
||||
/* === End RFC 0001 === */
|
||||
|
|
|
@ -40,7 +40,7 @@ const grantErrorContaining = (code: string, description: string, status = 400) =
|
|||
const accessDeniedError = grantErrorContaining(
|
||||
'oidc.access_denied',
|
||||
'user is not a member of the organization',
|
||||
400
|
||||
403
|
||||
);
|
||||
|
||||
const issuer = defaultConfig.endpoint + '/oidc';
|
||||
|
|
Loading…
Add table
Reference in a new issue