Skip to content

goat: Create service auth token via locally-held signing key #1122

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

Merged

Conversation

DavidBuchanan314
Copy link
Collaborator

@DavidBuchanan314 DavidBuchanan314 commented Jul 17, 2025

This is needed as part of the "adversarial PDS migration" flow, because the existing goat account service-auth command requires the origin PDS to create the token.

NAME:
   goat account service-auth-offline - create service auth token via locally-held signing key

USAGE:
   goat account service-auth-offline [command options] [arguments...]

OPTIONS:
   --atproto-signing-key value    private key used to sign the token (multibase syntax) [$ATPROTO_SIGNING_KEY]
   --iss value                    the DID of the account issuing the token
   --endpoint value, --lxm value  restrict token to API endpoint (NSID, optional)
   --audience value, --aud value  DID of service that will receive and validate token
   --duration-sec value           validity time window of token (seconds) (default: 0)
   --help, -h                     show help

@DavidBuchanan314
Copy link
Collaborator Author

DavidBuchanan314 commented Jul 18, 2025

I've tested this now (as part of a migration) so can confidently say that it works at least

Very much open to suggestions on renaming things or moving the subcommand to a different category, but I thought this made the most sense.

@DavidBuchanan314 DavidBuchanan314 marked this pull request as ready for review July 18, 2025 12:56
Copy link
Collaborator

@bnewbold bnewbold left a comment

Choose a reason for hiding this comment

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

left some minor nit comments, but overall good! glad you found the auth signing package

},
&cli.IntFlag{
Name: "duration-sec",
Value: 60,
Copy link
Collaborator

Choose a reason for hiding this comment

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

My intuition is to bump this up to something between 120 to 300 seconds for folks doing this manually/locally? Though I guess this is basically the same with service-auth (fetched from PDS, but output locally) and consistency is good. And too-long a duration might be rejected by the audience. I'd probably bump to 120 but also fine leaving as-is, up to you.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do you think it's likely for a too-long duration to be rejected by the audience outright, or just treated as if it were a shorter one?

I think I'll leave this as-is since it's nice to have a "safer" default (and enforces the convention that service auth tokens are intended to be short-lived in general), but in my writeup I set the duration to 3600

durSec := cctx.Int("duration-sec")
duration := time.Duration(durSec * int(time.Second))

token, err := auth.SignServiceAuth(iss, aud, duration, lxm, privkey)
Copy link
Collaborator

Choose a reason for hiding this comment

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

yay, glad you found this and that it can be used here!

@DavidBuchanan314 DavidBuchanan314 merged commit 2b66462 into bluesky-social:main Jul 21, 2025
2 checks passed
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