Skip to content
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

use password4j to generate and check hashes #3313

Merged
merged 5 commits into from
Feb 29, 2024

Conversation

thoniTUB
Copy link
Collaborator

@thoniTUB thoniTUB commented Feb 22, 2024

Don't use PBKDF2 anymore

Signed-off-by: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
Signed-off-by: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
Signed-off-by: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
@thoniTUB thoniTUB marked this pull request as ready for review February 28, 2024 14:25
Copy link
Collaborator

@awildturtok awildturtok left a comment

Choose a reason for hiding this comment

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

Sieht im ganzen gut aus. Finde etwas Spooky, dass wir jetzt doch Strings statt char[] benutzen. Die password4j ist sehr etabliert, oder warum der umstieg?

}
HashEntry hashedEntry = passwordStore.get(new UserId(username));
if (hashedEntry == null) {
throw new UnknownAccountException("Provided username or password was not valid.");
Copy link
Collaborator

Choose a reason for hiding this comment

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

Best Practice ist hier idR auch IncorrectCredentials oä zu werfen um zu verhindern, dass Leute für deinen Account fishen können.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Guter Punkt, passe ich an :)

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ich bleibe bei den Exceptions explizit im Realm, aber fange und konvertiere sie zu einer generellen NotAuthorizedException die ein 401er aus lösen bevor sie zum User kommen.

CompressedPBKDF2Function.class, CompressedPBKDF2Function::getInstanceFromHash
);

HashingFunction getHashingFunction(String hash) {
Copy link
Collaborator

Choose a reason for hiding this comment

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

ich verstehe nicht was die methode macht

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Ich habe eine doku ergänzt und einen Test dazu geschrieben.

Du gibst der methode einen hash und sie gibt dir die HashingFunction zurück, mit der sie erstellt wurde.

…or the end user

Signed-off-by: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
Signed-off-by: Max Thonagel <12283268+thoniTUB@users.noreply.github.com>
@thoniTUB
Copy link
Collaborator Author

Sieht im ganzen gut aus. Finde etwas Spooky, dass wir jetzt doch Strings statt char[] benutzen. Die password4j ist sehr etabliert, oder warum der umstieg?

Ich habe mich umgeschaut. Ich habe mich zu der lib entschieden, weil sie einfach zu bedienen ist und die akuellen Algorithmen unterstützt. die Alternative wäre z.B. die Spring Security Lib zu importieren, aber das ist ein overkill oder für die einzelnen Algorithmen einzelne Libs zu importieren.
Shiro hat auch Crypto Support, aber sehr veraltet

@thoniTUB thoniTUB merged commit 82a4a61 into feature/remove-api-token-realm Feb 29, 2024
2 checks passed
@delete-merged-branch delete-merged-branch bot deleted the fix/update-password-hashing branch February 29, 2024 14:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants