-
Notifications
You must be signed in to change notification settings - Fork 3
redirect org users to org dashboard #2482
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
Conversation
bb784f5
to
0e2996f
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Two things I have noticed:
- This requires keycloak
26.3.3
(or higher, presumably; It did not work on26.2.3
) - I believe the setting
KEYCLOAK_SCOPES="openid profile ol-profile organization:*"
causes problems for people who have not yet enabled orgs.
To see (2) in effect, remove "organization" from client scope and try logging in via UI. You will see:

and an "invalid scope" error in keycloak logs
keycloak-1 | 2025-09-05 19:00:36,476 WARN [org.keycloak.events] (executor-thread-18) type="LOGIN_ERROR", realmId="160c333f-6b79-44a1-8bfc-e9ca019584bb", realmName="ol-local", clientId="apisix", userId="null", ipAddress="192.168.65.1", error="invalid_request", reason="Invalid scopes: openid profile ol-profile organization:*", response_type="code", redirect_uri="http://api.learn.odl.local:8065/login/.apisix/redirect", response_mode="query"
I think we should try to update the ol-local-realm.json
realm export (I do not know how) or leave KEYCLOAK_SCOPES
as-is for now.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for all the help testing this. Keycloak 26.3.3 was the key for me.
Two requested changes:
- Redirect with
APP_BASE_URL
- Do something about
KEYCLOAK_SCOPES="openid profile ol-profile organization:*"
breaking stuff.- IMO best would be to update the realm JSON... James mentioned in slack we can export the realm via https://www.keycloak.org/server/importExport
- Even if we update it, existing (local) keycloaks would need to be manually updated, though, I think.
authentication/views.py
Outdated
org_slug, | ||
) | ||
|
||
redirect_url = f"/dashboard/organization/{org_slug}" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This took me to http://api.learn.odl.local:8065/dashboard/organization/universityx
which was 404 since it's an API url not an app URL.
Probably we want urljoin(settings.APP_BASE_URL, f"/dashboard/organization/{org_slug}")
…re determined to be a part of, if they are a part of one
for more information, see https://pre-commit.ci
…ding for org users
b4f3734
to
305fa64
Compare
@ChristopherChudzicki Thanks for the review. I took your suggestion for the redirect using |
What are the relevant tickets?
Closes https://github.com/mitodl/hq/issues/8011
Description (What does it do?)
This PR modifies the custom login view in Learn to check if the user is part of any organizations (as determined by Keycloak and passed on by APISIX) and if so, skips onboarding and redirects them to the dashboard for their given organization
How can this be tested?
Keycloak Config:
KEYCLOAK_SVC_ADMIN
/KEYCLOAK_SVC_ADMIN_PASSWORD
ol-local
realm (instead of themaster
realm)organization
apisix
clientorganization
scope we just created and add it