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

Permits to only support login via hashed API tokens #1975

Merged
merged 1 commit into from
Apr 29, 2024

Conversation

andyHa
Copy link
Member

@andyHa andyHa commented Apr 11, 2024

API tokens have already been deprecated for some time. Still some legacy systems need to support this approach. However, some systems now at least only rely in hashed tokens, which are way more secure as simply accepting a plaintext token which is also stored as plaintext in the DB.

Therefore, we now permit a more fine grained control over how kind of API tokens and authentication can be used.

Within the system config, next to "accept-api-tokens" one can also specify "accept-hashed-api-tokens". The former controls whether plaintext API keys can be used "just like a password" and the latter controls if a properly hashed version of the token is accepted. These two flags operate independently of each other.

NOTE: If "accept-api-tokens" was / is enabled, please review carefully, if now "accept-hashed-api-tokens" should be enabled, and also, if "accept-api-tokens" could be disabled after this change.

Description

Additional Notes

  • This PR fixes or works on following ticket(s): SIRI-
  • This PR is related to PR:

Checklist

  • Code change has been tested and works locally
  • Code was formatted via IntelliJ and follows SonarLint & best practices
  • Patch Tasks: Is local execution of Patch Tasks necessary? If so, please also mark the PR with the tag.

API tokens have already been deprecated for some time. Still some legacy
systems need to support this approach. However, some systems now at least
only rely in hashed tokens, which are way more secure as simply accepting
a plaintext token which is also stored as plaintext in the DB.

Therefore, we now permit a more fine grained control over how kind of
API tokens and authentication can be used.

Within the system config, next to "accept-api-tokens" one can also specify
"accept-hashed-api-tokens". The former controls whether plaintext API
keys can be used "just like a password" and the latter controls if a properly
hashed version of the token is accepted. These two flags operate independently
of each other.

NOTE: If "accept-api-tokens" was / is enabled, please review carefully, if now
"accept-hashed-api-tokens" should be enabled, and also, if "accept-api-tokens"
could be disabled after this change.
@andyHa andyHa added 🧬 Enhancement Contains new features 💣 BREAKING CHANGE Contains non-backwards compatible changes to public methods or changes the behavior of existing code 🎁 Next version Not part of the current version we are working and should not be merged labels Apr 11, 2024
@andyHa andyHa marked this pull request as ready for review April 11, 2024 08:57
@@ -662,7 +664,7 @@ public UserInfo findUserByCredentials(@Nullable WebContext webContext, String us
return result;
}

if (acceptApiTokens && checkApiToken(loginData, password)) {
if (checkApiToken(loginData, password)) {
Copy link
Member

Choose a reason for hiding this comment

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

The new version looks good to me. I don't understand, though, why there ever was a acceptApiTokens here. Does that setting change meaning with this PR?

@sabieber sabieber removed the 🎁 Next version Not part of the current version we are working and should not be merged label Apr 29, 2024
@sabieber sabieber merged commit 67d42af into develop Apr 29, 2024
3 of 7 checks passed
@sabieber sabieber deleted the feature/aha/support-hashed-api-tokens branch April 29, 2024 13:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💣 BREAKING CHANGE Contains non-backwards compatible changes to public methods or changes the behavior of existing code 🧬 Enhancement Contains new features
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants