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

compatibility with last keycloak version #396

Merged
merged 1 commit into from
Nov 22, 2022
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
9 changes: 5 additions & 4 deletions core/lcsb/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
def get_keycloak_config_from_settings() -> Dict:
return {
'KEYCLOAK_URL': getattr(settings, 'KEYCLOAK_URL'),
'KEYCLOAK_REALM': getattr(settings, 'KEYCLOAK_REALM'),
'KEYCLOAK_REALM_LOGIN': getattr(settings, 'KEYCLOAK_REALM_LOGIN'),
'KEYCLOAK_REALM_ADMIN': getattr(settings, 'KEYCLOAK_REALM_ADMIN'),
'KEYCLOAK_USER': getattr(settings, 'KEYCLOAK_USER'),
'KEYCLOAK_PASS': getattr(settings, 'KEYCLOAK_PASS')
}
Expand All @@ -34,7 +35,7 @@ def __init__(self, config: Dict, connect=True) -> None:

@staticmethod
def _validate_config(config: Dict) -> None:
keys = ['KEYCLOAK_URL', 'KEYCLOAK_USER', 'KEYCLOAK_PASS', 'KEYCLOAK_REALM']
keys = ['KEYCLOAK_URL', 'KEYCLOAK_USER', 'KEYCLOAK_PASS', 'KEYCLOAK_REALM_LOGIN', 'KEYCLOAK_REALM_ADMIN']
for key in keys:
if key not in config:
raise KeyError(f"'{key}' missing in KeycloakAdmin configuration!")
Expand All @@ -52,7 +53,8 @@ def _create_connection(self, config:Dict=None) -> KeycloakAdmin:
self._validate_config(self.config)
admin = KeycloakAdmin(
server_url=self.config.get('KEYCLOAK_URL'),
realm_name=self.config.get('KEYCLOAK_REALM'),
realm_name=self.config.get('KEYCLOAK_REALM_ADMIN'),
user_realm_name=self.config.get('KEYCLOAK_REALM_LOGIN'),
username=self.config.get('KEYCLOAK_USER'),
password=self.config.get('KEYCLOAK_PASS'),
verify=False
Expand Down Expand Up @@ -243,4 +245,3 @@ def _did_something_change(self):
return True
else:
return self._cached_external_accounts != self.current_external_accounts

2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@
'psycopg2-binary==2.9.3',
'pysolr==3.8.1',
'pytest-runner==5.1',
'python-keycloak==0.26.1',
'python-keycloak==2.6.0',
'pytz==2022.1',
'requests==2.25.1',
'urllib3==1.26.5',
Expand Down