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): return GNAP 404 error if token cannot be rotated #3101

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/auth/src/accessToken/routes.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -484,12 +484,12 @@ describe('Access Token Routes', (): void => {
)
})

test('Returns status 400 if could not rotate token', async (): Promise<void> => {
test('Returns status 404 if could not rotate token', async (): Promise<void> => {
const ctx = createTokenHttpSigContext(token, grant)
jest.spyOn(accessTokenService, 'rotate').mockResolvedValueOnce(undefined)

await expect(accessTokenRoutes.rotate(ctx)).rejects.toMatchObject({
status: 400,
status: 404,
code: GNAPErrorCode.InvalidRotation,
message: 'invalid access token'
})
Expand Down
2 changes: 1 addition & 1 deletion packages/auth/src/accessToken/routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,7 @@ async function rotateToken(
const errorMessage =
error instanceof Error ? error.message : 'Could not rotate token'
throw new GNAPServerRouteError(
400,
404,
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we throw in the other service methods that may lead to this 404? or do we just want this error message for the if (!newToken) case?

Copy link
Contributor

Choose a reason for hiding this comment

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

CC @njlie

GNAPErrorCode.InvalidRotation,
errorMessage
)
Expand Down
Loading