-
Notifications
You must be signed in to change notification settings - Fork 1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Verify client scopes before accepting token
- Loading branch information
Showing
7 changed files
with
69 additions
and
16 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,7 +18,7 @@ | |
KEYCLOAK_ADMIN_PASSWORD = "admin" | ||
KEYCLOAK_TEST_USERNAME = "gxyuser" | ||
KEYCLOAK_TEST_PASSWORD = "gxypass" | ||
KEYCLOAK_HOST_PORT = 9443 | ||
KEYCLOAK_HOST_PORT = 8443 | ||
KEYCLOAK_URL = f"https://localhost:{KEYCLOAK_HOST_PORT}/realms/gxyrealm" | ||
|
||
|
||
|
@@ -128,7 +128,7 @@ def configure_oidc_and_restart(cls): | |
|
||
@classmethod | ||
def tearDownClass(cls): | ||
# stop_keycloak_docker(cls.container_name) | ||
stop_keycloak_docker(cls.container_name) | ||
cls.restoreOauthlibHttps() | ||
os.remove(cls.backend_config_file) | ||
super().tearDownClass() | ||
|
@@ -250,7 +250,9 @@ def test_auth_with_expired_token(self): | |
|
||
def test_auth_with_another_authorized_client(self): | ||
_, response = self._login_via_keycloak(KEYCLOAK_TEST_USERNAME, KEYCLOAK_TEST_PASSWORD) | ||
access_token = self._get_keycloak_access_token(client_id="bpaclient", scopes=["gx:*"]) | ||
access_token = self._get_keycloak_access_token( | ||
client_id="bpaclient", scopes=["https://galaxyproject.org/api:*"] | ||
) | ||
response = self._get("users/current", headers={"Authorization": f"Bearer {access_token}"}) | ||
self._assert_status_code_is(response, 200) | ||
assert response.json()["email"] == "[email protected]" | ||
|
@@ -266,3 +268,8 @@ def test_auth_with_unauthorized_client(self): | |
access_token = self._get_keycloak_access_token(client_id="unauthorizedclient") | ||
response = self._get("users/current", headers={"Authorization": f"Bearer {access_token}"}) | ||
self._assert_status_code_is(response, 400) | ||
|
||
def test_auth_without_required_scopes(self): | ||
access_token = self._get_keycloak_access_token(client_id="bpaclient") | ||
response = self._get("users/current", headers={"Authorization": f"Bearer {access_token}"}) | ||
self._assert_status_code_is(response, 400) |