From 827da59ae28cd315b4f1373107a8a9396e20d1fa Mon Sep 17 00:00:00 2001 From: Matt Scott Date: Sun, 9 Apr 2023 10:26:07 -0400 Subject: [PATCH] Working on Knockout model integration into existing authentication settings editor view. --- powerdnsadmin/models/setting.py | 4 ++ .../js/app-authentication-settings-editor.js | 6 +- .../admin_setting_authentication.html | 68 +++++++++++++------ 3 files changed, 55 insertions(+), 23 deletions(-) diff --git a/powerdnsadmin/models/setting.py b/powerdnsadmin/models/setting.py index 1ef3166..80a72c1 100644 --- a/powerdnsadmin/models/setting.py +++ b/powerdnsadmin/models/setting.py @@ -93,6 +93,7 @@ class Setting(db.Model): 'google_oauth_client_secret': '', 'google_oauth_scope': 'openid email profile', 'google_base_url': 'https://www.googleapis.com/oauth2/v3/', + 'google_oauth_auto_configure': True, 'google_oauth_metadata_url': 'https://accounts.google.com/.well-known/openid-configuration', 'google_token_url': 'https://oauth2.googleapis.com/token', 'google_authorize_url': 'https://accounts.google.com/o/oauth2/v2/auth', @@ -103,6 +104,7 @@ class Setting(db.Model): 'github_oauth_secret': '', 'github_oauth_scope': 'email', 'github_oauth_api_url': 'https://api.github.com/user', + 'github_oauth_auto_configure': False, 'github_oauth_metadata_url': '', 'github_oauth_token_url': 'https://github.com/login/oauth/access_token', 'github_oauth_authorize_url': 'https://github.com/login/oauth/authorize', @@ -113,6 +115,7 @@ class Setting(db.Model): 'azure_oauth_secret': '', 'azure_oauth_scope': 'User.Read openid email profile', 'azure_oauth_api_url': 'https://graph.microsoft.com/v1.0/', + 'azure_oauth_auto_configure': True, 'azure_oauth_metadata_url': '', 'azure_oauth_token_url': '', 'azure_oauth_authorize_url': '', @@ -132,6 +135,7 @@ class Setting(db.Model): 'oidc_oauth_secret': '', 'oidc_oauth_scope': 'email', 'oidc_oauth_api_url': '', + 'oidc_oauth_auto_configure': True, 'oidc_oauth_metadata_url': '', 'oidc_oauth_token_url': '', 'oidc_oauth_authorize_url': '', diff --git a/powerdnsadmin/static/custom/js/app-authentication-settings-editor.js b/powerdnsadmin/static/custom/js/app-authentication-settings-editor.js index 104b3e9..db2530e 100644 --- a/powerdnsadmin/static/custom/js/app-authentication-settings-editor.js +++ b/powerdnsadmin/static/custom/js/app-authentication-settings-editor.js @@ -46,7 +46,7 @@ let AuthenticationSettingsModel = function (user_data, csrf_token, selector) { google_oauth_client_secret: '', google_oauth_scope: '', google_base_url: '', - google_oauth_auto_configure: false, + google_oauth_auto_configure: true, google_oauth_metadata_url: '', google_token_url: '', google_authorize_url: '', @@ -68,7 +68,7 @@ let AuthenticationSettingsModel = function (user_data, csrf_token, selector) { azure_oauth_secret: '', azure_oauth_scope: '', azure_oauth_api_url: '', - azure_oauth_auto_configure: false, + azure_oauth_auto_configure: true, azure_oauth_metadata_url: '', azure_oauth_token_url: '', azure_oauth_authorize_url: '', @@ -88,7 +88,7 @@ let AuthenticationSettingsModel = function (user_data, csrf_token, selector) { oidc_oauth_secret: '', oidc_oauth_scope: '', oidc_oauth_api_url: '', - oidc_oauth_auto_configure: false, + oidc_oauth_auto_configure: true, oidc_oauth_metadata_url: '', oidc_oauth_token_url: '', oidc_oauth_authorize_url: '', diff --git a/powerdnsadmin/templates/admin_setting_authentication.html b/powerdnsadmin/templates/admin_setting_authentication.html index 73d305d..a20671b 100644 --- a/powerdnsadmin/templates/admin_setting_authentication.html +++ b/powerdnsadmin/templates/admin_setting_authentication.html @@ -798,6 +798,13 @@
+ + +
+
+ data-bind="enable: google_oauth_enabled() && google_oauth_auto_configure(), value: google_oauth_metadata_url, valueUpdate: 'afterkeydown'">
-
+
+ data-bind="enable: google_oauth_enabled() && !google_oauth_auto_configure(), value: google_token_url, valueUpdate: 'afterkeydown'">
-
+
+ data-bind="enable: google_oauth_enabled() && !google_oauth_auto_configure(), value: google_authorize_url, valueUpdate: 'afterkeydown'">
@@ -927,6 +934,13 @@
+ + +
+
+ data-bind="enable: github_oauth_enabled() && github_oauth_auto_configure(), value: github_oauth_metadata_url, valueUpdate: 'afterkeydown'">
-
+
+ data-bind="enable: github_oauth_enabled() && !github_oauth_auto_configure(), value: github_oauth_token_url, valueUpdate: 'afterkeydown'">
-
+
+ data-bind="enable: github_oauth_enabled() && !github_oauth_auto_configure(), value: github_oauth_authorize_url, valueUpdate: 'afterkeydown'">
@@ -1056,6 +1070,13 @@
+ + +
+
+ data-bind="enable: azure_oauth_enabled() && azure_oauth_auto_configure(), value: azure_oauth_metadata_url, valueUpdate: 'afterkeydown'">
-
+
+ data-bind="enable: azure_oauth_enabled() && !azure_oauth_auto_configure(), value: azure_oauth_token_url, valueUpdate: 'afterkeydown'">
-
+
+ data-bind="enable: azure_oauth_enabled() && !azure_oauth_auto_configure(), value: azure_oauth_authorize_url, valueUpdate: 'afterkeydown'">
@@ -1362,6 +1383,13 @@
+ + +
+
+ data-bind="enable: oidc_oauth_enabled() && oidc_oauth_auto_configure(), value: oidc_oauth_metadata_url, valueUpdate: 'afterkeydown'">
-
+
+ data-bind="enable: oidc_oauth_enabled() && !oidc_oauth_auto_configure(), value: oidc_oauth_token_url, valueUpdate: 'afterkeydown'">
-
+
+ data-bind="enable: oidc_oauth_enabled() && !oidc_oauth_auto_configure(), value: oidc_oauth_authorize_url, valueUpdate: 'afterkeydown'">