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

fix for keycloak authentication #411

Merged
merged 1 commit into from
Dec 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/keycloak_setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ the DNS name and port for the Keycloak server. Replace "keycloak_realm" with th
in Keycloak.

openid_provider: keycloak # Use "keycloak" as the authentication provider
openid_url: http://<server_dns>:<server_port>/auth/realms/<keycloak_realm>/.well-known/openid-configuration # update to use your Keycloak location and realm
openid_url: http://<server_dns>:<server_port>/realms/<keycloak_realm>/.well-known/openid-configuration # update to use your Keycloak location and realm
openid_audience: account # OpenID audience. Keycloak client id.
openid_claims: preferred_username,appid # Comma seperated list of claims to resolve to usernames.

Expand Down
7 changes: 6 additions & 1 deletion hsds/util/jwtUtil.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def verifyBearerToken(app, token):
log.warn(msg)
raise HTTPInternalServerError()
if res.status_code != 200:
log.warn("Bad response from {openid_url}: {res.status_code}")
log.warn(f"Bad response from {openid_url}: {res.status_code}")
if res.status_code == 404:
raise HTTPNotFound()
elif res.status_code == 401:
Expand Down Expand Up @@ -183,6 +183,11 @@ def verifyBearerToken(app, token):
log.debug(f"got value: {value} for claim: {name}")
if name == "unique_name":
username = value
elif name == "preferred_username":
if username:
log.debug(f"ignoring {name} since preferred_username is set")
else:
username = value
elif name == "appid":
pass # tbd
elif name == "roles":
Expand Down
1 change: 1 addition & 0 deletions tests/unit/chunk_util_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def testGuessChunk(self):

shape = {"class": "H5S_SIMPLE", "dims": [100, 100, 100]}
layout = guessChunk(shape, typesize)
print("layout:", layout)
self.assertTrue(len(layout), 3)
for i in range(3):
self.assertTrue(layout[i] >= 1)
Expand Down
Loading