Skip to content

Commit

Permalink
PDS - inspect bearer tokens (#2688)
Browse files Browse the repository at this point in the history
* inspect bearer tokens to determine if theyre access tokens or service auth tokens

* changeset
  • Loading branch information
dholms authored Aug 5, 2024
1 parent b0a5fa3 commit 269cbc8
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
5 changes: 5 additions & 0 deletions .changeset/curvy-jeans-dream.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@atproto/pds": patch
---

Inspect bearer auth token on uploadBlob
11 changes: 7 additions & 4 deletions packages/pds/src/auth-verifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -249,11 +249,14 @@ export class AuthVerifier {
accessOrUserServiceAuth =
(opts: Partial<AccessOpts> = {}) =>
async (ctx: ReqCtx): Promise<UserServiceAuthOutput | AccessOutput> => {
try {
return await this.accessStandard(opts)(ctx)
} catch {
return await this.userServiceAuth(ctx)
const token = bearerTokenFromReq(ctx.req)
if (token) {
const payload = jose.decodeJwt(token)
if (payload['lxm']) {
return this.userServiceAuth(ctx)
}
}
return this.accessStandard(opts)(ctx)
}

modService = async (ctx: ReqCtx): Promise<ModServiceOutput> => {
Expand Down

0 comments on commit 269cbc8

Please sign in to comment.