From bc82edb2d163b26ab4f7fef8a736e8de2752d6c3 Mon Sep 17 00:00:00 2001 From: Joseph Schorr Date: Fri, 9 Jun 2017 17:12:05 -0400 Subject: [PATCH] Add ability to configure OIDC internal auth engine via superuser panel --- data/users/oidc.py | 6 ++- oauth/oidc.py | 2 +- .../directives/config/config-setup-tool.html | 40 ++++++++++++++----- static/js/core-config-setup.js | 12 +++++- util/config/validator.py | 2 + .../validators/test/test_validate_oidcauth.py | 32 +++++++++++++++ util/config/validators/validate_oidcauth.py | 23 +++++++++++ 7 files changed, 103 insertions(+), 14 deletions(-) create mode 100644 util/config/validators/test/test_validate_oidcauth.py create mode 100644 util/config/validators/validate_oidcauth.py diff --git a/data/users/oidc.py b/data/users/oidc.py index 1014b513a..8c7831bf2 100644 --- a/data/users/oidc.py +++ b/data/users/oidc.py @@ -9,6 +9,10 @@ from util.security.jwtutil import InvalidTokenError logger = logging.getLogger(__name__) +class UnknownServiceException(Exception): + pass + + class OIDCInternalAuth(FederatedUsers): """ Handles authentication by delegating authentication to a signed OIDC JWT produced by the configured OIDC service. @@ -18,7 +22,7 @@ class OIDCInternalAuth(FederatedUsers): login_manager = OAuthLoginManager(config) self.login_service = login_manager.get_service(login_service_id) if self.login_service is None: - raise Exception('Unknown OIDC login service %s' % login_service_id) + raise UnknownServiceException('Unknown OIDC login service %s' % login_service_id) @property def supports_encrypted_credentials(self): diff --git a/oauth/oidc.py b/oauth/oidc.py index f5c9249a2..2b7272652 100644 --- a/oauth/oidc.py +++ b/oauth/oidc.py @@ -39,7 +39,7 @@ class OIDCLoginService(OAuthService): self._public_key_cache = TTLCache(1, PUBLIC_KEY_CACHE_TTL, missing=self._load_public_key) self._id = key_name[0:key_name.find('_')].lower() - self._http_client = client or config['HTTPCLIENT'] + self._http_client = client or config.get('HTTPCLIENT') self._mailing = config.get('FEATURE_MAILING', False) def service_id(self): diff --git a/static/directives/config/config-setup-tool.html b/static/directives/config/config-setup-tool.html index 09368ba1f..0f68a78cb 100644 --- a/static/directives/config/config-setup-tool.html +++ b/static/directives/config/config-setup-tool.html @@ -622,21 +622,23 @@

- Authentication for the registry can be handled by either the registry itself, LDAP or external JWT endpoint. + Authentication for the registry can be handled by either the registry itself, LDAP, Keystone, OIDC or external JWT endpoint.

Additional external authentication providers (such as GitHub) can be used in addition for login into the UI.

-
- It is highly recommended to require encrypted client passwords. External passwords used in the Docker client will be stored in plaintext! - Enable this requirement now. -
+
+
+ It is highly recommended to require encrypted client passwords. External passwords used in the Docker client will be stored in plaintext! + Enable this requirement now. +
-
- Note: The "Require Encrypted Client Passwords" feature is currently enabled which will - prevent passwords from being saved as plaintext by the Docker client. +
+ Note: The "Require Encrypted Client Passwords" feature is currently enabled which will + prevent passwords from being saved as plaintext by the Docker client. +
@@ -648,6 +650,7 @@ + @@ -687,6 +690,21 @@
+ + + + + + +
OIDC Provider: + +
+ An OIDC provider must be configured to use this authentication system +
+
+ @@ -1073,7 +1091,7 @@ (Delete)
-
+
Warning: This OIDC provider is not bound to your {{ config.AUTHENTICATION_TYPE }} authentication. Logging in via this provider will create a -only user, which is not the recommended approach. It is highly recommended to choose a "Binding Field" below.
@@ -1134,7 +1152,7 @@
- +
Binding Field: