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

Use proper error when authed account is not found #1799

Merged
merged 1 commit into from
Nov 1, 2023
Merged
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
6 changes: 6 additions & 0 deletions packages/pds/src/auth-verifier.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { KeyObject, createPublicKey, createSecretKey } from 'node:crypto'
import {
AuthRequiredError,
ForbiddenError,
InvalidRequestError,
verifyJwt as verifyServiceJwt,
} from '@atproto/xrpc-server'
Expand All @@ -10,6 +11,7 @@ import express from 'express'
import * as jose from 'jose'
import KeyEncoder from 'key-encoder'
import { AccountManager } from './account-manager'
import { softDeleted } from './db'

type ReqCtx = {
req: express.Request
Expand Down Expand Up @@ -121,6 +123,10 @@ export class AuthVerifier {
])
const found = await this.accountManager.getAccount(result.credentials.did)
if (!found) {
// will be turned into ExpiredToken for the client if proxied by entryway
throw new ForbiddenError('Account not found', 'AccountNotFound')
}
if (softDeleted(found)) {
throw new AuthRequiredError(
'Account has been taken down',
'AccountTakedown',
Expand Down
Loading