Skip to content

Conversation

@alemsh
Copy link
Contributor

@alemsh alemsh commented Jan 17, 2024

Premise

Currently, clowder2 relies on an internal keycloak instance for handling authentication, but does not have functionality for using an existing keycloak instance. This should be pretty simple but requires a few changes to some of the requests made back to the keycloak server for oauth2 flow.

Changes

  • Change the auth and token requests to use the python-keycloak packages KeycloakOpenID object to construct these URLs/requests.
  • Add an auth_redirect_uri environment variable instead of constructing it in each request
  • Update helm values.yaml to include an auth section to override the auth_server_url environment variable, as well as add environment variables for auth_realm, auth_client_id, auth_redirect_uri

Comments

Tested this with docker compose, and both local and external keycloak instances in kubernetes deployed with helm in kubernetes

@CLAassistant
Copy link

CLAassistant commented Jan 17, 2024

CLA assistant check
All committers have signed the CLA.

@lmarini
Copy link
Member

lmarini commented Jan 17, 2024

Thanks for submitting this PR @alemsh ! Could you please sign the CLA? Also can you take a look at #862 and see how it compares to yours?

@tcnichol @longshuicy can you also please take a look at this and compare it to #862.

Thanks!

@alemsh
Copy link
Contributor Author

alemsh commented Jan 17, 2024

Ah, I had signed it but was using my org email for the commit, had to verify it.

I think #862 looks good, but this commit should be for a separate issue, but would be necessary in case the keycloak realm uses something else other than email for a preferred_username (as is our case). I believe these two PRs should solve the issues we've ran into.

@lmarini
Copy link
Member

lmarini commented Jan 18, 2024

Ah, I had signed it but was using my org email for the commit, had to verify it.

I think #862 looks good, but this commit should be for a separate issue, but would be necessary in case the keycloak realm uses something else other than email for a preferred_username (as is our case). I believe these two PRs should solve the issues we've ran into.

Thanks @alemsh , we will take a closer look. Would you be able to test #862 in your environment? Thank you.

@alemsh
Copy link
Contributor Author

alemsh commented Jan 19, 2024

Thanks @alemsh , we will take a closer look. Would you be able to test #862 in your environment? Thank you.

Can confirm that is looks like it is working quite well in our environment

@longshuicy
Copy link
Member

is it possible to make one minor change of the default config so our dev stack works seamlessly? Instead of the fixing the redirect url to port 80, can we allow the flexibility of using the HOST_API; and I realize host api have to be localhost instead of 127.0.0.1 to match our default keycloak setting.
Details see below:
image

Everything else looks good!

@alemsh
Copy link
Contributor Author

alemsh commented Jan 24, 2024

is it possible to make one minor change of the default config so our dev stack works seamlessly? Instead of the fixing the redirect url to port 80, can we allow the flexibility of using the HOST_API; and I realize host api have to be localhost instead of 127.0.0.1 to match our default keycloak setting. Details see below:

Sure thing @longshuicy . Should we also add the API_V2_STR as well? like

auth_redirect_uri = f"{API_HOST}{API_V2_STR}/auth"

@longshuicy
Copy link
Member

is it possible to make one minor change of the default config so our dev stack works seamlessly? Instead of the fixing the redirect url to port 80, can we allow the flexibility of using the HOST_API; and I realize host api have to be localhost instead of 127.0.0.1 to match our default keycloak setting. Details see below:

Sure thing @longshuicy . Should we also add the API_V2_STR as well? like

auth_redirect_uri = f"{API_HOST}{API_V2_STR}/auth"

Yes that will be awesome. Nice catch :D

Copy link
Contributor

@tcnichol tcnichol left a comment

Choose a reason for hiding this comment

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

marking approved ready to merge.

@longshuicy longshuicy merged commit 51c5e89 into clowder-framework:main Feb 2, 2024
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.

5 participants