Skip to content

Conversation

@kradalby
Copy link
Collaborator

@kradalby kradalby commented Nov 1, 2025

this commit changes the underlying implementation of pre auth keys to the same as our API keys. This means that instead of having a key in the database, it will consist of a prefix and a bcrypt hash.

This improves the security of the keys as they can not be read back in the case of a database getting away.

Old keys still work, but all new keys are created in the new format.

All keys are prefixed with "hskey-auth" to indicate their purpose.

claude was used in this PR.

@kradalby kradalby force-pushed the kradalby/preauthkey-bcrypt branch from 336a8e5 to 151a49e Compare November 2, 2025 00:11
@kradalby kradalby added this to the v0.28.0 milestone Nov 2, 2025
@kradalby kradalby force-pushed the kradalby/preauthkey-bcrypt branch from 151a49e to d49ae71 Compare November 2, 2025 14:27
@kradalby kradalby force-pushed the kradalby/preauthkey-bcrypt branch from d49ae71 to 5657d93 Compare November 11, 2025 20:44
@kradalby kradalby marked this pull request as ready for review November 11, 2025 20:46
@kradalby kradalby marked this pull request as draft November 11, 2025 21:01
@kradalby kradalby force-pushed the kradalby/preauthkey-bcrypt branch from 5657d93 to 7231e9f Compare November 11, 2025 21:47
@kradalby kradalby marked this pull request as ready for review November 11, 2025 21:48
@kradalby kradalby force-pushed the kradalby/preauthkey-bcrypt branch 2 times, most recently from 8e745b7 to 26e52b7 Compare November 12, 2025 14:15
this commit changes the underlying implementation of
pre auth keys to the same as our API keys. This means that
instead of having a key in the database, it will consist
of a prefix and a bcrypt hash.

This improves the security of the keys as they can not be
read back in the case of a database getting away.

Old keys still work, but all new keys are created in the
new format.

All keys are prefixed with "hskey-auth" to indicate their
purpose.

Signed-off-by: Kristoffer Dalby <kristoffer@tailscale.com>
New API keys use hskey-api-{prefix}-{secret} format with bcrypt
hashing. Legacy keys without prefix continue to work.
Add registration keys (hskey-reg-{64-char-random}) for tracking web
authentication registration flows in logs. These vanity keys are not
stored in the database and do not use bcrypt - they exist purely for
observability and correlating log entries during the registration process.
PreAuthKeyNew.Proto() was only returning ID and Key fields, causing the
gRPC CreatePreAuthKey response to omit Ephemeral, Reusable, and other
fields. This broke integration tests expecting these values.

Add all fields to PreAuthKeyNew struct and populate them in
CreatePreAuthKey. Update Proto() method to include all fields with
proper protobuf timestamp conversion.
@kradalby kradalby force-pushed the kradalby/preauthkey-bcrypt branch from 26e52b7 to e7a7dcc Compare November 12, 2025 15:10
@kradalby kradalby merged commit da9018a into juanfont:main Nov 12, 2025
93 of 98 checks passed
@kradalby kradalby mentioned this pull request Nov 20, 2025
2 tasks
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