@@ -384,18 +384,27 @@ def camelCaseify(s):
384384 auth_config = c [auth_class_name ]
385385 auth_config .update (get_config ('auth.custom.config' ) or {})
386386elif auth_type == 'keycloak' :
387+ from cloudharness .applications import get_configuration
388+ from cloudharness .utils .config import CloudharnessConfig
387389 from oauthenticator .generic import GenericOAuthenticator
388390
391+ accounts_app = get_configuration ('accounts' )
392+
393+ accounts_url = accounts_app .get_public_address ()
394+ client_id = accounts_app .conf .webclient .id
395+ client_secret = accounts_app .conf .webclient .secret
396+ realm = CloudharnessConfig .get_namespace ()
397+
389398 c .JupyterHub .authenticator_class = GenericOAuthenticator
390- c .OAuthenticator . oauth_callback_url = "http://minianhub.mnp.local/hub/oauth_callback"
391- c .OAuthenticator .client_id = "web-client"
392- c .OAuthenticator .client_secret = "452952ae-922c-4766-b912-7b106271e34b"
399+ c .Authenticator . auto_login = True
400+ c .OAuthenticator .client_id = client_id
401+ c .OAuthenticator .client_secret = client_secret
393402
394- c .GenericOAuthenticator .login_service = "keycloak "
403+ c .GenericOAuthenticator .login_service = "CH "
395404 c .GenericOAuthenticator .username_key = "email"
396- c .GenericOAuthenticator .authorize_url = "http://accounts.mnp.local/ auth/realms/mnp /protocol/openid-connect/auth"
397- c .GenericOAuthenticator .token_url = "http://accounts.mnp.local/ auth/realms/mnp /protocol/openid-connect/token"
398- c .GenericOAuthenticator .userdata_url = "http://accounts.mnp.local/ auth/realms/mnp /protocol/openid-connect/userinfo"
405+ c .GenericOAuthenticator .authorize_url = f" { accounts_url } / auth/realms/{ realm } /protocol/openid-connect/auth"
406+ c .GenericOAuthenticator .token_url = f" { accounts_url } / auth/realms/{ realm } /protocol/openid-connect/token"
407+ c .GenericOAuthenticator .userdata_url = f" { accounts_url } / auth/realms/{ realm } /protocol/openid-connect/userinfo"
399408 c .GenericOAuthenticator .userdata_params = {'state' : 'state' }
400409else :
401410 raise ValueError ("Unhandled auth type: %r" % auth_type )
@@ -532,4 +541,5 @@ def camelCaseify(s):
532541 exec (config_py )
533542
534543c .apps = get_config ('apps' )
535- c .registry = get_config ('registry' )
544+ c .registry = get_config ('registry' )
545+ c .domain = get_config ('root.domain' )
0 commit comments