diff --git a/powerdnsadmin/models/setting.py b/powerdnsadmin/models/setting.py index b225787..0f6f35d 100644 --- a/powerdnsadmin/models/setting.py +++ b/powerdnsadmin/models/setting.py @@ -88,6 +88,10 @@ class Setting(db.Model): 'oidc_oauth_api_url': '', 'oidc_oauth_token_url': '', 'oidc_oauth_authorize_url': '', + 'oidc_oauth_username': 'preferred_username', + 'oidc_oauth_firstname': 'given_name', + 'oidc_oauth_last_name': 'family_name ', + 'oidc_oauth_email': 'email', 'forward_records_allow_edit': { 'A': True, 'AAAA': True, diff --git a/powerdnsadmin/routes/admin.py b/powerdnsadmin/routes/admin.py index 4ee8b58..e56778e 100644 --- a/powerdnsadmin/routes/admin.py +++ b/powerdnsadmin/routes/admin.py @@ -811,6 +811,14 @@ def setting_authentication(): request.form.get('oidc_oauth_token_url')) Setting().set('oidc_oauth_authorize_url', request.form.get('oidc_oauth_authorize_url')) + Setting().set('oidc_oauth_username', + request.form.get('oidc_oauth_username')) + Setting().set('oidc_oauth_firstname', + request.form.get('oidc_oauth_firstname')) + Setting().set('oidc_oauth_last_name', + request.form.get('oidc_oauth_last_name')) + Setting().set('oidc_oauth_email', + request.form.get('oidc_oauth_email')) result = { 'status': True, 'msg': diff --git a/powerdnsadmin/routes/index.py b/powerdnsadmin/routes/index.py index 4df19e8..8e58c88 100644 --- a/powerdnsadmin/routes/index.py +++ b/powerdnsadmin/routes/index.py @@ -285,10 +285,10 @@ def login(): if 'oidc_token' in session: me = json.loads(oidc.get('userinfo').text) - oidc_username = me["preferred_username"] - oidc_givenname = me["name"] - oidc_familyname = "" - oidc_email = me["email"] + oidc_username = me[Setting().get('oidc_oauth_username')] + oidc_givenname = me[Setting().get('oidc_oauth_firstname')] + oidc_familyname = me[Setting().get('oidc_oauth_last_name')] + oidc_email = me[Setting().get('oidc_oauth_email')] user = User.query.filter_by(username=oidc_username).first() if not user: diff --git a/powerdnsadmin/templates/admin_setting_authentication.html b/powerdnsadmin/templates/admin_setting_authentication.html index 50c00ef..5d91801 100644 --- a/powerdnsadmin/templates/admin_setting_authentication.html +++ b/powerdnsadmin/templates/admin_setting_authentication.html @@ -526,6 +526,29 @@ +