-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Default to SSHA-256
as API key stored credential hasher
#120997
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
elasticsearchmachine
merged 31 commits into
elastic:main
from
n1v0lg:api-key-stored-hash
Jan 29, 2025
Merged
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
74118b1
WIP
n1v0lg f3e00ca
Separate stored hash method
n1v0lg b2269e8
More
n1v0lg df2b60c
Merge branch 'main' into api-key-stored-hash
n1v0lg f3aeba9
Fix NPE
n1v0lg 2ea9110
Merge branch 'main' into api-key-stored-hash
n1v0lg 0fde9ec
Tweak
n1v0lg 82a1ce7
Clean up randomness
n1v0lg a1094cc
Update docs/changelog/120997.yaml
n1v0lg 14d5774
Undo
n1v0lg 1d8b4b1
Merge branch 'api-key-stored-hash' of github.com:n1v0lg/elasticsearch…
n1v0lg 61a960c
Docs etc
n1v0lg 22bb9ce
Merge branch 'main' into api-key-stored-hash
n1v0lg 872ab87
More docs
n1v0lg 4346eb8
Merge branch 'api-key-stored-hash' of github.com:n1v0lg/elasticsearch…
n1v0lg 064bbca
Link to FIPS docs
n1v0lg 5d19199
Docs nits
n1v0lg ede049c
es
n1v0lg 18db8e6
Merge branch 'main' into api-key-stored-hash
n1v0lg 7fd23da
Handle FIPS mode
n1v0lg ed954c2
Fix docs
n1v0lg daaef9b
Merge branch 'main' into api-key-stored-hash
n1v0lg 94746ae
Merge branch 'main' into api-key-stored-hash
n1v0lg de8c8f6
Fix and test
n1v0lg 949cb0b
Merge branch 'api-key-stored-hash' of github.com:n1v0lg/elasticsearch…
n1v0lg 62a447e
One more
n1v0lg eb97f47
Javadoc
n1v0lg 35ba1bd
Merge branch 'main' into api-key-stored-hash
n1v0lg 2389206
Merge branch 'main' into api-key-stored-hash
n1v0lg 681a971
Merge branch 'main' into api-key-stored-hash
n1v0lg 5099653
Merge branch 'main' into api-key-stored-hash
n1v0lg File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
pr: 120997 | ||
summary: Allow `SSHA-256` for API key credential hash | ||
area: Authentication | ||
type: enhancement | ||
issues: [] |
This file contains hidden or 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
This file contains hidden or 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
41 changes: 41 additions & 0 deletions
41
server/src/main/java/org/elasticsearch/common/SecureRandomUtils.java
This file contains hidden or 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* Copyright Elasticsearch B.V. and/or licensed to Elasticsearch B.V. under one | ||
* or more contributor license agreements. Licensed under the "Elastic License | ||
* 2.0", the "GNU Affero General Public License v3.0 only", and the "Server Side | ||
* Public License v 1"; you may not use this file except in compliance with, at | ||
* your election, the "Elastic License 2.0", the "GNU Affero General Public | ||
* License v3.0 only", or the "Server Side Public License, v 1". | ||
*/ | ||
|
||
package org.elasticsearch.common; | ||
|
||
import org.elasticsearch.common.settings.SecureString; | ||
import org.elasticsearch.core.CharArrays; | ||
|
||
import java.util.Arrays; | ||
import java.util.Base64; | ||
|
||
public final class SecureRandomUtils { | ||
private SecureRandomUtils() {} | ||
|
||
/** | ||
* Returns a cryptographically secure Base64 encoded {@link SecureString} of {@code numBytes} random bytes. | ||
*/ | ||
public static SecureString getBase64SecureRandomString(int numBytes) { | ||
byte[] randomBytes = null; | ||
byte[] encodedBytes = null; | ||
try { | ||
randomBytes = new byte[numBytes]; | ||
SecureRandomHolder.INSTANCE.nextBytes(randomBytes); | ||
encodedBytes = Base64.getUrlEncoder().withoutPadding().encode(randomBytes); | ||
return new SecureString(CharArrays.utf8BytesToChars(encodedBytes)); | ||
} finally { | ||
if (randomBytes != null) { | ||
Arrays.fill(randomBytes, (byte) 0); | ||
} | ||
if (encodedBytes != null) { | ||
Arrays.fill(encodedBytes, (byte) 0); | ||
} | ||
} | ||
} | ||
} |
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
This file contains hidden or 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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.