-
Notifications
You must be signed in to change notification settings - Fork 648
Add SecureToken to enforce good token hygiene #3320
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
Add SecureToken to enforce good token hygiene #3320
Conversation
.collect() | ||
} | ||
|
||
macro_rules! secure_token_kind { |
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 find this a bit hard to read. Did you consider using something like strum
instead of this custom macro? If we'll still go with the custom macro I think it'd be good to add a few more doc comments on it at least :)
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 don't think it's worth bringing another dependency in just for this. I'll try to add some comments to the macro.
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 guess this is also fine to retrofit. I'm approving the PR in the meantime :)
This commit adds the `SecureToken` struct, which relies on the type system to enforce good practices for generating and verifying tokens: * `SecureToken` forces adding an unique prefix in front of every kind of generated token. This allows token scanning services to properly identify tokens generated by crates.io, and allows crates.io to detect which kind of token it's about to revoke. * `SecureToken` only stores and exposes the SHA256 of already generated tokens, to prevent accidental plaintext leakages. The plaintext token value is only exposes for newly generated tokens.
7211160
to
7ce54f4
Compare
7ce54f4
to
46840ca
Compare
@bors r+ |
📌 Commit 46840ca has been approved by |
Add SecureToken to enforce good token hygiene This PR adds the `SecureToken` struct, which relies on the type system to enforce good practices for generating and verifying tokens: * `SecureToken` forces adding an unique prefix in front of every kind of generated token. This allows token scanning services to properly identify tokens generated by crates.io, and allows crates.io to detect which kind of token it's about to revoke. * `SecureToken` only stores and exposes the SHA256 of already generated tokens, to prevent accidental plaintext leakages. The plaintext token value is only exposes for newly generated tokens. r? `@Turbo87`
💔 Test failed - checks-actions |
@bors retry |
☀️ Test successful - checks-actions |
This PR adds the
SecureToken
struct, which relies on the type system to enforce good practices for generating and verifying tokens:SecureToken
forces adding an unique prefix in front of every kind of generated token. This allows token scanning services to properly identify tokens generated by crates.io, and allows crates.io to detect which kind of token it's about to revoke.SecureToken
only stores and exposes the SHA256 of already generated tokens, to prevent accidental plaintext leakages. The plaintext token value is only exposes for newly generated tokens.r? @Turbo87