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

Service auth method binding - PDS #2668

Merged
merged 16 commits into from
Aug 5, 2024
Merged

Service auth method binding - PDS #2668

merged 16 commits into from
Aug 5, 2024

Conversation

dholms
Copy link
Collaborator

@dholms dholms commented Jul 29, 2024

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.

@dholms dholms marked this pull request as ready for review July 29, 2024 22:20
@dholms dholms changed the title Service auth scopes - PDS Service auth method binding - PDS Jul 30, 2024
@@ -0,0 +1,6 @@
---
"@atproto/xrpc-server": minor
Copy link
Collaborator

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?

Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like it is 👍

Comment on lines 20 to 22
} else if (diff > MINUTE) {
throw new InvalidRequestError(
'cannot request a token with an expiration more than an hour in the future',
Copy link
Collaborator

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:

Suggested change
} 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',

Comment on lines +14 to +19
const diff = exp - Date.now()
if (diff < 0) {
throw new InvalidRequestError(
'expiration is in past',
'BadExpiration',
)
Copy link
Collaborator

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.

Comment on lines 310 to 311
export const parseReqNsid = (req: express.Request): string => {
return req.originalUrl.split('?')[0].replace('/xrpc/', '')
Copy link
Collaborator

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.

Copy link
Collaborator

@devinivy devinivy left a 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!

@dholms dholms merged commit dc471da into main Aug 5, 2024
10 checks passed
@dholms dholms deleted the service-auth-scopes-pds branch August 5, 2024 20:09
@github-actions github-actions bot mentioned this pull request Aug 5, 2024
estrattonbailey added a commit that referenced this pull request Aug 15, 2024
* 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)
haileyok pushed a commit that referenced this pull request Aug 16, 2024
* 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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants