-
-
Notifications
You must be signed in to change notification settings - Fork 275
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
Feature/hash api keys #2249
Merged
acelaya
merged 13 commits into
shlinkio:develop
from
acelaya-forks:feature/hash-api-keys
Nov 9, 2024
Merged
Feature/hash api keys #2249
acelaya
merged 13 commits into
shlinkio:develop
from
acelaya-forks:feature/hash-api-keys
Nov 9, 2024
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2249 +/- ##
=============================================
+ Coverage 93.53% 93.61% +0.07%
- Complexity 1611 1635 +24
=============================================
Files 270 271 +1
Lines 5631 5716 +85
=============================================
+ Hits 5267 5351 +84
- Misses 364 365 +1 ☔ View full report in Codecov by Sentry. |
acelaya
force-pushed
the
feature/hash-api-keys
branch
from
November 5, 2024 22:27
e6b1a38
to
1b9c837
Compare
acelaya
force-pushed
the
feature/hash-api-keys
branch
from
November 6, 2024 07:57
caca78b
to
f6d70c5
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #2193
This PR improves how Shlink handles API keys, by hashing them before they are persisted, improving security.
The hashing algorithm used for keys is SHA256, for two reasons mainly:
Since API keys are v4 UUIDs, they provide enough uniqueness and entropy, so there's no need for a more advanced hashing algorithm, with salts, iterations, etc. SHA256 should be fine for this use case.
Backwards compatibility
It s very important to not break any existing instances when people update to this version. Because of that, existing API keys will be hashed for everything to continue working, but since it's possible people was trusting Shlink to list their keys, all plain-text values have been set in the
name
field.Once updated, Shlink now provides a new
api-key:rename
console command that they can use to set more meaningful names to their keys and securely save the plain-text values.For newly created API keys via
api-key:generate
, the process has changed a bit. The name is now recommended to be provided, and Shlink will verify it is unique.However, if a name is not provided, Shlink will generate one using a redacted version of the API key. For example, if the key is
8fff91e5-11ce-452a-8be9-8660ee3b966c
, the name will be8fff91e5-****-****-****-************
.The
api-key:disable
command has also been slightly changed. For backwards compatibility, it still allows to disable keys by the key value itself (api-key:disable 8fff91e5-11ce-452a-8be9-8660ee3b966c
), but that is now considered deprecated.Instead, users should provide the name and indicate it via
--by-name
:api-key:disable the-name --by-name
.TODO:
142e0b2c-****-****-****-************
)