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

refactor: keycloak PR remaining TODOs #742

Merged
merged 8 commits into from
May 27, 2024
Merged

Conversation

fmartingr
Copy link
Contributor

Summary

  • Moved the parsing of the authentication type from an user from an users file to a separate function and added tests
  • Use a template file instead of code to populate the keycloak.env file
  • Set the user in the store directly in the Login/SignUp methods instead of authOpenID method.

@fmartingr fmartingr self-assigned this May 10, 2024
api/utils.go Outdated
// user represents a user in the users.txt file
// The format of each line in the file is:
// (authentication_type:)?email password
func parseUserFromLine(u user) (username, email, password, authenticationType string) {
Copy link
Contributor

Choose a reason for hiding this comment

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

The more I look at this the more I am wondering whether this logic should be part of getUserCredentials. Would that make sense or are there further complexities?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah that's probably a better place for it:

Copy link
Member

@agnivade agnivade left a comment

Choose a reason for hiding this comment

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

Looks good, but could you please give this a test with a fresh deployment?


switch ue.config.AuthenticationType {
case AuthenticationTypeOpenID:
if err := ue.authOpenID(authOpenIDLogin); err != nil {
return fmt.Errorf("error while logging in using OpenID: %w", err)
}

loggedUser, _, err = ue.client.GetUserByUsername(context.Background(), user.Username, "")
Copy link
Member

Choose a reason for hiding this comment

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

Ah okay, so Signup already had the right code. We just hadn't applied it to Login? That feels a bit weird.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, in my changes (thinking it wasn't working at that particular time because of a Keycloak issue) I forgot that Login should store the user the same way as SignUp does.

@fmartingr fmartingr requested a review from streamer45 May 20, 2024 08:52
Copy link
Contributor

@streamer45 streamer45 left a comment

Choose a reason for hiding this comment

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

Thanks, looks great!

@fmartingr
Copy link
Contributor Author

but could you please give this a test with a fresh deployment?

I tested this locally and can confirm that users can login correctly using openID

@fmartingr fmartingr merged commit 6aa5938 into master May 27, 2024
1 check passed
@fmartingr fmartingr deleted the dangling-keycloak-issues branch May 27, 2024 08:55
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants