-
Notifications
You must be signed in to change notification settings - Fork 554
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
Service auth method binding - PDS #2668
Conversation
@@ -0,0 +1,6 @@ | |||
--- | |||
"@atproto/xrpc-server": minor |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just confirming— this is a breaking change in xrpc-server?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like it is 👍
} else if (diff > MINUTE) { | ||
throw new InvalidRequestError( | ||
'cannot request a token with an expiration more than an hour in the future', |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I expect the error text here is right and the check needs to be corrected:
} else if (diff > MINUTE) { | |
throw new InvalidRequestError( | |
'cannot request a token with an expiration more than an hour in the future', | |
} else if (diff > HOUR) { | |
throw new InvalidRequestError( | |
'cannot request a token with an expiration more than an hour in the future', |
const diff = exp - Date.now() | ||
if (diff < 0) { | ||
throw new InvalidRequestError( | ||
'expiration is in past', | ||
'BadExpiration', | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One trick about using exp
versus something like a duration is that it gets another clock in the mix (our server plus the requester), plus whatever latency between the servers. I do like that it's a passthrough to the jwt claim, though. Not strong feels/suggestions here, just an observation.
packages/xrpc-server/src/util.ts
Outdated
export const parseReqNsid = (req: express.Request): string => { | ||
return req.originalUrl.split('?')[0].replace('/xrpc/', '') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wonder if a trailing slash might throw this off.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Tossed in a few ideas, but this is looking great!
* origin/main: Provide a ponyfill for CustomEvent (#2710) Ensure presence of DPoP related response headers (#2711) prettier ignore changelogs, as changesets not resolving prettier config properly Version packages (#2709) Export `AtpAgentOptions` type from @atproto/api (#2708) tidy Version packages (#2706) Update changeset to better reflect changes (#2707) Client SDK rework (#2483) Allow aud of pds or entryway for service auth tokens on pds (#2694) Version packages (#2692) Lex-cli prettier changes changeset (#2691) Version packages (#2689) PDS - inspect bearer tokens (#2688) Version packages (#2685) Service auth method binding - PDS (#2668) minor typos in descriptions and comments (#2681) Fix run-dev-env-logged command (#2682) Version packages (#2677) Tweak some wording in `oauth-client-browser` readme (#2678)
* pds changes only * use scope for ozone service profile * dont verify scopes on pds yet * tidy * tidy imports * changeset * add tests * another changeset * scope -> lxm * tidy * update nonce size * pr feedback * trim trailing slash * nonce -> jti * fix xrpc-server test * allow service auth on uploadBlob
Just the PDS implementation of #2663
This allows us to deploy our PDSs & publish a PDS distribution so that PDSs start emitting method-bound service auth tokens. Once the changes have had time to roll out, we can then deploy #2663 more broadly to start checking for methods on service auth tokens.
This PR does not lift the restriction that an app password is unable to call
server.getServiceAuth
. This prevents a capability escalation attack where an app-password account could request a scoped service auth token that a sensitive service (such as chat) may not properly check.