mirror of
https://github.com/cwinfo/powerdns-admin.git
synced 2024-12-04 19:15:30 +00:00
Merge branch 'custom_current_user' of https://github.com/benshalev849/PowerDNS-Admin into custom_current_user
This commit is contained in:
commit
6a402969ec
1
.github/workflows/mega-linter.yml
vendored
1
.github/workflows/mega-linter.yml
vendored
@ -6,6 +6,7 @@ name: MegaLinter
|
||||
on:
|
||||
push:
|
||||
branches-ignore:
|
||||
- "*"
|
||||
- "dev"
|
||||
- "main"
|
||||
- "master"
|
||||
|
@ -28,8 +28,8 @@ class Setting(db.Model):
|
||||
'allow_user_create_domain': False,
|
||||
'allow_user_remove_domain': False,
|
||||
'allow_user_view_history': False,
|
||||
'delete_sso_accounts': False,
|
||||
'custom_history_header': '',
|
||||
'delete_sso_accounts': False,
|
||||
'bg_domain_updates': False,
|
||||
'enable_api_rr_history': True,
|
||||
'preserve_history': False,
|
||||
@ -45,7 +45,7 @@ class Setting(db.Model):
|
||||
'local_db_enabled': True,
|
||||
'signup_enabled': True,
|
||||
'autoprovisioning': False,
|
||||
'urn_value':'',
|
||||
'urn_value': '',
|
||||
'autoprovisioning_attribute': '',
|
||||
'purge': False,
|
||||
'verify_user_email': False,
|
||||
@ -70,15 +70,19 @@ class Setting(db.Model):
|
||||
'github_oauth_scope': 'email',
|
||||
'github_oauth_api_url': 'https://api.github.com/user',
|
||||
'github_oauth_token_url':
|
||||
'https://github.com/login/oauth/access_token',
|
||||
'https://github.com/login/oauth/access_token',
|
||||
'github_oauth_authorize_url':
|
||||
'https://github.com/login/oauth/authorize',
|
||||
'https://github.com/login/oauth/authorize',
|
||||
'github_oauth_jwks_url': '',
|
||||
'github_oauth_metadata_url': '',
|
||||
'google_oauth_enabled': False,
|
||||
'google_oauth_client_id': '',
|
||||
'google_oauth_client_secret': '',
|
||||
'google_token_url': 'https://oauth2.googleapis.com/token',
|
||||
'google_oauth_scope': 'openid email profile',
|
||||
'google_authorize_url': 'https://accounts.google.com/o/oauth2/v2/auth',
|
||||
'google_oauth_jwks_url': '',
|
||||
'google_oauth_metadata_url': '',
|
||||
'google_base_url': 'https://www.googleapis.com/oauth2/v3/',
|
||||
'azure_oauth_enabled': False,
|
||||
'azure_oauth_key': '',
|
||||
@ -86,9 +90,11 @@ class Setting(db.Model):
|
||||
'azure_oauth_scope': 'User.Read openid email profile',
|
||||
'azure_oauth_api_url': 'https://graph.microsoft.com/v1.0/',
|
||||
'azure_oauth_token_url':
|
||||
'https://login.microsoftonline.com/[tenancy]/oauth2/v2.0/token',
|
||||
'https://login.microsoftonline.com/[tenancy]/oauth2/v2.0/token',
|
||||
'azure_oauth_authorize_url':
|
||||
'https://login.microsoftonline.com/[tenancy]/oauth2/v2.0/authorize',
|
||||
'https://login.microsoftonline.com/[tenancy]/oauth2/v2.0/authorize',
|
||||
'azure_oauth_jwks_url': '',
|
||||
'azure_oauth_metadata_url': '',
|
||||
'azure_sg_enabled': False,
|
||||
'azure_admin_group': '',
|
||||
'azure_operator_group': '',
|
||||
@ -105,6 +111,7 @@ class Setting(db.Model):
|
||||
'oidc_oauth_api_url': '',
|
||||
'oidc_oauth_token_url': '',
|
||||
'oidc_oauth_authorize_url': '',
|
||||
'oidc_oauth_jwks_url': '',
|
||||
'oidc_oauth_metadata_url': '',
|
||||
'oidc_oauth_logout_url': '',
|
||||
'oidc_oauth_username': 'preferred_username',
|
||||
@ -285,7 +292,7 @@ class Setting(db.Model):
|
||||
result = self.query.filter(Setting.name == setting).first()
|
||||
|
||||
if result is not None:
|
||||
if hasattr(result,'value'):
|
||||
if hasattr(result, 'value'):
|
||||
result = result.value
|
||||
return strtobool(result) if result in [
|
||||
'True', 'False'
|
||||
|
@ -1637,12 +1637,16 @@ def setting_authentication():
|
||||
request.form.get('google_oauth_client_id'))
|
||||
Setting().set('google_oauth_client_secret',
|
||||
request.form.get('google_oauth_client_secret'))
|
||||
Setting().set('google_oauth_metadata_url',
|
||||
request.form.get('google_oauth_metadata_url'))
|
||||
Setting().set('google_token_url',
|
||||
request.form.get('google_token_url'))
|
||||
Setting().set('google_oauth_scope',
|
||||
request.form.get('google_oauth_scope'))
|
||||
Setting().set('google_authorize_url',
|
||||
request.form.get('google_authorize_url'))
|
||||
Setting().set('google_oauth_jwks_url',
|
||||
request.form.get('google_oauth_jwks_url'))
|
||||
Setting().set('google_base_url',
|
||||
request.form.get('google_base_url'))
|
||||
result = {
|
||||
@ -1670,10 +1674,14 @@ def setting_authentication():
|
||||
request.form.get('github_oauth_scope'))
|
||||
Setting().set('github_oauth_api_url',
|
||||
request.form.get('github_oauth_api_url'))
|
||||
Setting().set('github_oauth_metadata_url',
|
||||
request.form.get('github_oauth_metadata_url'))
|
||||
Setting().set('github_oauth_token_url',
|
||||
request.form.get('github_oauth_token_url'))
|
||||
Setting().set('github_oauth_authorize_url',
|
||||
request.form.get('github_oauth_authorize_url'))
|
||||
Setting().set('github_oauth_jwks_url',
|
||||
request.form.get('github_oauth_jwks_url'))
|
||||
result = {
|
||||
'status': True,
|
||||
'msg':
|
||||
@ -1699,10 +1707,14 @@ def setting_authentication():
|
||||
request.form.get('azure_oauth_scope'))
|
||||
Setting().set('azure_oauth_api_url',
|
||||
request.form.get('azure_oauth_api_url'))
|
||||
Setting().set('azure_oauth_metadata_url',
|
||||
request.form.get('azure_oauth_metadata_url'))
|
||||
Setting().set('azure_oauth_token_url',
|
||||
request.form.get('azure_oauth_token_url'))
|
||||
Setting().set('azure_oauth_authorize_url',
|
||||
request.form.get('azure_oauth_authorize_url'))
|
||||
Setting().set('azure_oauth_jwks_url',
|
||||
request.form.get('azure_oauth_jwks_url'))
|
||||
Setting().set(
|
||||
'azure_sg_enabled', True
|
||||
if request.form.get('azure_sg_enabled') == 'ON' else False)
|
||||
@ -1750,12 +1762,14 @@ def setting_authentication():
|
||||
request.form.get('oidc_oauth_scope'))
|
||||
Setting().set('oidc_oauth_api_url',
|
||||
request.form.get('oidc_oauth_api_url'))
|
||||
Setting().set('oidc_oauth_metadata_url',
|
||||
request.form.get('oidc_oauth_metadata_url'))
|
||||
Setting().set('oidc_oauth_token_url',
|
||||
request.form.get('oidc_oauth_token_url'))
|
||||
Setting().set('oidc_oauth_authorize_url',
|
||||
request.form.get('oidc_oauth_authorize_url'))
|
||||
Setting().set('oidc_oauth_metadata_url',
|
||||
request.form.get('oidc_oauth_metadata_url'))
|
||||
Setting().set('oidc_oauth_jwks_url',
|
||||
request.form.get('oidc_oauth_jwks_url'))
|
||||
Setting().set('oidc_oauth_logout_url',
|
||||
request.form.get('oidc_oauth_logout_url'))
|
||||
Setting().set('oidc_oauth_username',
|
||||
|
@ -23,6 +23,8 @@ def azure_oauth():
|
||||
request_token_url=None,
|
||||
access_token_url=Setting().get('azure_oauth_token_url'),
|
||||
authorize_url=Setting().get('azure_oauth_authorize_url'),
|
||||
jwks_url=Setting().get('azure_oauth_jwks_url'),
|
||||
server_metadata_url=Setting().get('azure_oauth_metadata_url'),
|
||||
client_kwargs={'scope': Setting().get('azure_oauth_scope')},
|
||||
fetch_token=fetch_azure_token,
|
||||
)
|
||||
|
@ -24,6 +24,8 @@ def github_oauth():
|
||||
request_token_url=None,
|
||||
access_token_url=Setting().get('github_oauth_token_url'),
|
||||
authorize_url=Setting().get('github_oauth_authorize_url'),
|
||||
jwks_url=Setting().get('github_oauth_jwks_url'),
|
||||
server_metadata_url=Setting().get('github_oauth_metadata_url'),
|
||||
client_kwargs={'scope': Setting().get('github_oauth_scope')},
|
||||
fetch_token=fetch_github_token,
|
||||
update_token=update_token)
|
||||
|
@ -23,6 +23,8 @@ def google_oauth():
|
||||
request_token_url=None,
|
||||
access_token_url=Setting().get('google_token_url'),
|
||||
authorize_url=Setting().get('google_authorize_url'),
|
||||
jwks_url=Setting().get('google_oauth_jwks_url'),
|
||||
server_metadata_url=Setting().get('google_oauth_metadata_url'),
|
||||
client_kwargs={'scope': Setting().get('google_oauth_scope')},
|
||||
fetch_token=fetch_google_token,
|
||||
update_token=update_token)
|
||||
|
@ -23,6 +23,7 @@ def oidc_oauth():
|
||||
request_token_url=None,
|
||||
access_token_url=Setting().get('oidc_oauth_token_url'),
|
||||
authorize_url=Setting().get('oidc_oauth_authorize_url'),
|
||||
jwks_url=Setting().get('oidc_oauth_jwks_url'),
|
||||
server_metadata_url=Setting().get('oidc_oauth_metadata_url'),
|
||||
client_kwargs={'scope': Setting().get('oidc_oauth_scope')},
|
||||
fetch_token=fetch_oidc_token,
|
||||
|
@ -630,9 +630,16 @@
|
||||
value="{{ SETTING.get('google_oauth_client_secret') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>ADVANCE</legend>
|
||||
<div class="form-group">
|
||||
<label for="google_oauth_metadata_url">Metadata URL</label>
|
||||
<input type="text" class="form-control"
|
||||
name="google_oauth_metadata_url"
|
||||
id="google_oauth_metadata_url"
|
||||
placeholder="e.g. https://{yourDomain}/.well-known/oauth-metadata.json"
|
||||
data-error="Please input Metadata URL"
|
||||
value="{{ SETTING.get('google_oauth_metadata_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="google_token_url">Token URL</label>
|
||||
<input type="text" class="form-control"
|
||||
@ -663,6 +670,17 @@
|
||||
value="{{ SETTING.get('google_authorize_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="google_oauth_jwks_url">JWKS
|
||||
URL</label>
|
||||
<input type="text" class="form-control"
|
||||
name="google_oauth_jwks_url"
|
||||
id="google_oauth_jwks_url"
|
||||
placeholder="e.g. https://{yourDomain}/.well-known/jwks.json"
|
||||
data-error="Please input JWKS URL"
|
||||
value="{{ SETTING.get('google_oauth_jwks_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="google_base_url">Base URL</label>
|
||||
<input type="text" class="form-control"
|
||||
@ -750,9 +768,6 @@
|
||||
value="{{ SETTING.get('github_oauth_secret') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>ADVANCE</legend>
|
||||
<div class="form-group">
|
||||
<label for="github_oauth_scope">Scope</label>
|
||||
<input type="text" class="form-control"
|
||||
@ -773,6 +788,16 @@
|
||||
value="{{ SETTING.get('github_oauth_api_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="github_oauth_metadata_url">Metadata URL</label>
|
||||
<input type="text" class="form-control"
|
||||
name="github_oauth_metadata_url"
|
||||
id="github_oauth_metadata_url"
|
||||
placeholder="e.g. https://{yourDomain}/.well-known/oauth-metadata.json"
|
||||
data-error="Please input Metadata URL"
|
||||
value="{{ SETTING.get('github_oauth_metadata_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="github_oauth_token_url">Token
|
||||
URL</label>
|
||||
@ -791,10 +816,21 @@
|
||||
name="github_oauth_authorize_url"
|
||||
id="github_oauth_authorize_url"
|
||||
placeholder="e.g. https://github.com/login/oauth/authorize"
|
||||
data-error="Plesae input Authorize URL"
|
||||
data-error="Please input Authorize URL"
|
||||
value="{{ SETTING.get('github_oauth_authorize_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="github_oauth_jwks_url">JWKS
|
||||
URL</label>
|
||||
<input type="text" class="form-control"
|
||||
name="github_oauth_jwks_url"
|
||||
id="github_oauth_jwks_url"
|
||||
placeholder="e.g. https://{yourDomain}/.well-known/jwks.json"
|
||||
data-error="Please input JWKS URL"
|
||||
value="{{ SETTING.get('github_oauth_jwks_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
</div>
|
||||
<!-- /.card-body -->
|
||||
@ -871,9 +907,6 @@
|
||||
value="{{ SETTING.get('azure_oauth_secret') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>ADVANCED</legend>
|
||||
<div class="form-group">
|
||||
<label for="azure_oauth_scope">Scope</label>
|
||||
<input type="text" class="form-control"
|
||||
@ -894,6 +927,16 @@
|
||||
value="{{ SETTING.get('azure_oauth_api_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="azure_oauth_metadata_url">Metadata URL</label>
|
||||
<input type="text" class="form-control"
|
||||
name="azure_oauth_metadata_url"
|
||||
id="azure_oauth_metadata_url"
|
||||
placeholder="e.g. https://{yourDomain}/.well-known/oauth-metadata.json"
|
||||
data-error="Please input Metadata URL"
|
||||
value="{{ SETTING.get('azure_oauth_metadata_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="azure_oauth_token_url">Token URL</label>
|
||||
<input type="text" class="form-control"
|
||||
@ -915,6 +958,17 @@
|
||||
value="{{ SETTING.get('azure_oauth_authorize_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="azure_oauth_jwks_url">JWKS
|
||||
URL</label>
|
||||
<input type="text" class="form-control"
|
||||
name="azure_oauth_jwks_url"
|
||||
id="azure_oauth_jwks_url"
|
||||
placeholder="e.g. https://{yourDomain}/.well-known/jwks.json"
|
||||
data-error="Please input JWKS URL"
|
||||
value="{{ SETTING.get('azure_oauth_jwks_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>GROUP SECURITY</legend>
|
||||
@ -1189,6 +1243,17 @@
|
||||
value="{{ SETTING.get('oidc_oauth_api_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="oidc_oauth_metadata_url">Metadata
|
||||
URL</label>
|
||||
<input type="text" class="form-control"
|
||||
name="oidc_oauth_metadata_url"
|
||||
id="oidc_oauth_metadata_url"
|
||||
placeholder="e.g. https://oidc.com/login/oauth/.well-known/openid-configuration"
|
||||
data-error="Please input Metadata URL"
|
||||
value="{{ SETTING.get('oidc_oauth_metadata_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="oidc_oauth_token_url">Token URL</label>
|
||||
<input type="text" class="form-control"
|
||||
@ -1206,19 +1271,19 @@
|
||||
name="oidc_oauth_authorize_url"
|
||||
id="oidc_oauth_authorize_url"
|
||||
placeholder="e.g. https://oidc.com/login/oauth/authorize"
|
||||
data-error="Plesae input Authorize URL"
|
||||
data-error="Please input Authorize URL"
|
||||
value="{{ SETTING.get('oidc_oauth_authorize_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="oidc_oauth_metadata_url">Metadata
|
||||
<label for="oidc_oauth_jwks_url">JWKS
|
||||
URL</label>
|
||||
<input type="text" class="form-control"
|
||||
name="oidc_oauth_metadata_url"
|
||||
id="oidc_oauth_metadata_url"
|
||||
placeholder="e.g. https://oidc.com/login/oauth/.well-known/openid-configuration"
|
||||
data-error="Plesae input Metadata URL"
|
||||
value="{{ SETTING.get('oidc_oauth_metadata_url') }}">
|
||||
name="oidc_oauth_jwks_url"
|
||||
id="oidc_oauth_jwks_url"
|
||||
placeholder="e.g. https://{yourDomain}/.well-known/jwks.json"
|
||||
data-error="Please input JWKS URL"
|
||||
value="{{ SETTING.get('oidc_oauth_jwks_url') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
@ -1234,7 +1299,7 @@
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>CLAIMS</legend>
|
||||
<legend>Claims</legend>
|
||||
<div class="form-group">
|
||||
<label for="oidc_oauth_username">Username</label>
|
||||
<input type="text" class="form-control"
|
||||
@ -1270,13 +1335,13 @@
|
||||
<input type="text" class="form-control"
|
||||
name="oidc_oauth_email" id="oidc_oauth_email"
|
||||
placeholder="e.g. email"
|
||||
data-error="Plesae input Email claim"
|
||||
data-error="Please input Email claim"
|
||||
value="{{ SETTING.get('oidc_oauth_email') }}">
|
||||
<span class="help-block with-errors"></span>
|
||||
</div>
|
||||
</fieldset>
|
||||
<fieldset>
|
||||
<legend>ADVANCE</legend>
|
||||
<legend>Advanced</legend>
|
||||
<div class="form-group">
|
||||
<label for="oidc_oauth_account_name_property">Autoprovision
|
||||
Account Name property</label>
|
||||
|
@ -101,14 +101,22 @@
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if current_user.role.name in ['Administrator', 'Operator'] %}
|
||||
<li class="nav-header">Administration</li>
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_global_search' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.global_search') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-search"></i>
|
||||
<p>Global Search</p>
|
||||
<li class="nav-header">Administration</li>
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_global_search' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.global_search') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-search"></i>
|
||||
<p>Global Search</p>
|
||||
</a>
|
||||
</li>
|
||||
{% if current_user.role.name in ['Administrator', 'Operator'] or SETTING.get('allow_user_view_history') %}
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_history' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.history') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-timeline"></i>
|
||||
<p>Activity</p>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
{% if current_user.role.name in ['Administrator', 'Operator'] %}
|
||||
<li class="{{ 'nav-item active' if active_page == 'server_statistics' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.server_statistics') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-chart-simple"></i>
|
||||
@ -121,12 +129,6 @@
|
||||
<p>Server Configuration</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_history' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.history') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-timeline"></i>
|
||||
<p>Activity</p>
|
||||
</a>
|
||||
</li>
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_domain_template' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.templates') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-clone"></i>
|
||||
@ -189,14 +191,6 @@
|
||||
{% endif %}
|
||||
</ul>
|
||||
</li>
|
||||
{% elif SETTING.get('allow_user_view_history') %}
|
||||
<li class="nav-header">Administration</li>
|
||||
<li class="{{ 'nav-item active' if active_page == 'admin_history' else 'nav-item' }}">
|
||||
<a href="{{ url_for('admin.history') }}" class="nav-link">
|
||||
<i class="nav-icon fa-solid fa-calendar-alt"></i>
|
||||
<p>History</p>
|
||||
</a>
|
||||
</li>
|
||||
{% endif %}
|
||||
</ul>
|
||||
{% endif %}
|
||||
|
Loading…
Reference in New Issue
Block a user