2018-08-18 11:41:59 +00:00
{% extends "base.html" %}
{% set active_page = "admin_settings" %}
{% block title %}
2018-08-18 15:42:18 +00:00
< title > Authentication Settings - {{ SITE_NAME }}< / title >
2018-08-18 11:41:59 +00:00
{% endblock %} {% block dashboard_stat %}
<!-- Content Header (Page header) -->
< section class = "content-header" >
< h1 >
Settings < small > PowerDNS-Admin settings< / small >
< / h1 >
< ol class = "breadcrumb" >
< li > < a href = "{{ url_for('dashboard') }}" > < i class = "fa fa-dashboard" > < / i > Home< / a > < / li >
< li > < a href = "#" > Setting< / a > < / li >
< li class = "active" > Authentication< / li >
< / ol >
< / section >
{% endblock %}
{% block content %}
< section class = "content" >
< div class = "row" >
< div class = "col-lg-12" >
< div class = "box box-primary" >
< div class = "box-header with-border" >
< h3 class = "box-title" > Authentication Settings< / h3 >
< / div >
< div class = "box-body" >
2018-08-19 15:08:14 +00:00
{% if result %}
< div class = "alert {% if result['status'] %}alert-success{% else %}alert-danger{% endif%} alert-dismissible" >
< button type = "button" class = "close" data-dismiss = "alert" aria-hidden = "true" > × < / button >
{{ result['msg'] }}
< / div >
{% endif %}
2018-08-18 11:41:59 +00:00
<!-- Custom Tabs -->
< div class = "nav-tabs-custom" id = "tabs" >
< ul class = "nav nav-tabs" >
< li class = "active" > < a href = "#tabs-general" data-toggle = "tab" > General< / a > < / li >
< li class = "active" > < a href = "#tabs-ldap" data-toggle = "tab" > LDAP< / a > < / li >
< li > < a href = "#tabs-google" data-toggle = "tab" > Google OAuth< / a > < / li >
< li > < a href = "#tabs-github" data-toggle = "tab" > Github OAuth< / a > < / li >
< / ul >
< div class = "tab-content" >
< div class = "tab-pane active" id = "tabs-general" >
< form role = "form" method = "post" >
< input type = "hidden" value = "general" name = "config_tab" / >
< div class = "form-group" >
< input type = "checkbox" id = "local_db_enabled" name = "local_db_enabled" class = "checkbox" { % if SETTING . get ( ' local_db_enabled ' ) % } checked { % endif % } >
< label for = "local_db_enabled" > Local DB Authentication< / label >
< / div >
< div class = "form-group" >
< input type = "checkbox" id = "signup_enabled" name = "signup_enabled" class = "checkbox" { % if SETTING . get ( ' signup_enabled ' ) % } checked { % endif % } >
< label for = "signup_enabled" > Allow users to sign up< / label >
< / div >
< div class = "form-group" >
< button type = "submit" class = "btn btn-flat btn-primary" > Save< / button >
< / div >
< / form >
< / div >
< div class = "tab-pane active" id = "tabs-ldap" >
< div class = "row" >
< div class = "col-md-4" >
2018-08-19 15:08:14 +00:00
< form role = "form" method = "post" data-toggle = "validator" >
2018-08-18 11:41:59 +00:00
< input type = "hidden" value = "ldap" name = "config_tab" / >
< fieldset >
< legend > GENERAL< / legend >
< div class = "form-group" >
< input type = "checkbox" id = "ldap_enabled" name = "ldap_enabled" class = "checkbox" { % if SETTING . get ( ' ldap_enabled ' ) % } checked { % endif % } >
< label for = "ldap_enabled" > Enable LDAP Authentication< / label >
< / div >
< div class = "form-group" >
< label > Type< / label >
< div class = "radio" >
< label >
< input type = "radio" name = "ldap_type" id = "ldap" value = "ldap" { % if SETTING . get ( ' ldap_type ' ) = = ' ldap ' % } checked { % endif % } > OpenLDAP
< / label >
< label >
< input type = "radio" name = "ldap_type" id = "ad" value = "ad" { % if SETTING . get ( ' ldap_type ' ) = = ' ad ' % } checked { % endif % } > Active Directory
< / label >
< / div >
< / div >
< / fieldset >
< fieldset >
< legend > ADMINISTRATOR INFO< / legend >
< div class = "form-group" >
< label for = "ldap_uri" > LDAP URI< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "ldap_uri" id = "ldap_uri" placeholder = "e.g. ldaps://your-ldap-server:636" data-error = "Please input LDAP URI" value = "{{ SETTING.get('ldap_uri') }}" >
2018-08-18 11:41:59 +00:00
< / div >
2018-08-18 15:42:18 +00:00
< div class = "form-group" >
< label for = "ldap_base_dn" > LDAP Base DN< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "ldap_base_dn" id = "ldap_base_dn" placeholder = "e.g. dc=mydomain,dc=com" data-error = "Please input LDAP Base DN" value = "{{ SETTING.get('ldap_base_dn') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 15:42:18 +00:00
< / div >
2018-08-18 11:41:59 +00:00
< div class = "form-group" >
< label for = "ldap_admin_username" > LDAP admin username< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "ldap_admin_username" id = "ldap_admin_username" placeholder = "e.g. cn=admin,dc=mydomain,dc=com" data-error = "Please input LDAP admin username" value = "{{ SETTING.get('ldap_admin_username') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "ldap_admin_password" > LDAP admin password< / label >
2018-08-19 15:08:14 +00:00
< input type = "password" class = "form-control" name = "ldap_admin_password" id = "ldap_admin_password" placeholder = "LDAP Admin password" data-error = "Please input LDAP admin password" value = "{{ SETTING.get('ldap_admin_password') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< / fieldset >
< fieldset >
< legend > FILTERS< / legend >
< div class = "form-group" >
< label for = "ldap_filter_basic" > Basic filter< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "ldap_filter_basic" id = "ldap_filter_basic" placeholder = "e.g. (objectClass=inetorgperson)" data-error = "Please input LDAP filter" value = "{{ SETTING.get('ldap_filter_basic') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "ldap_filter_username" > Username field< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "ldap_filter_username" id = "ldap_filter_username" placeholder = "e.g. uid" data-error = "Please input field for username filtering" value = "{{ SETTING.get('ldap_filter_username') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< / fieldset >
< fieldset >
< legend > GROUP SECURITY< / legend >
< div class = "form-group" >
< label > Status< / label >
< div class = "radio" >
< label >
< input type = "radio" name = "ldap_sg_enabled" id = "ldap_sg_off" value = "OFF" { % if not SETTING . get ( ' ldap_sg_enabled ' ) % } checked { % endif % } > OFF
< / label >
< label >
< input type = "radio" name = "ldap_sg_enabled" id = "ldap_sg_on" value = "ON" { % if SETTING . get ( ' ldap_sg_enabled ' ) % } checked { % endif % } > ON
< / label >
< / div >
< / div >
< div class = "form-group" >
< label for = "ldap_admin_group" > Admin group< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "ldap_admin_group" id = "ldap_admin_group" placeholder = "e.g. cn=sysops,dc=mydomain,dc=com" data-error = "Please input LDAP DN for Admin group" value = "{{ SETTING.get('ldap_admin_group') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "ldap_user_group" > User group< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "ldap_user_group" id = "ldap_user_group" placeholder = "e.g. cn=users,dc=mydomain,dc=com" data-error = "Please input LDAP DN for User group" value = "{{ SETTING.get('ldap_user_group') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< / fieldset >
< div class = "form-group" >
< button type = "submit" class = "btn btn-flat btn-primary" > Save< / button >
< / div >
< / form >
< / div >
< div class = "col-md-8" >
< legend > Help< / legend >
< p > TBD< / p >
< / div >
< / div >
< / div >
< div class = "tab-pane" id = "tabs-google" >
< div class = "row" >
< div class = "col-md-4" >
2018-08-19 15:08:14 +00:00
< form role = "form" method = "post" data-toggle = "validator" >
2018-08-18 11:41:59 +00:00
< input type = "hidden" value = "google" name = "config_tab" / >
< fieldset >
< legend > GENERAL< / legend >
< div class = "form-group" >
< input type = "checkbox" id = "google_oauth_enabled" name = "google_oauth_enabled" class = "checkbox" { % if SETTING . get ( ' google_oauth_enabled ' ) % } checked { % endif % } >
< label for = "google_oauth_enabled" > Enable Google OAuth< / label >
< / div >
< div class = "form-group" >
< label for = "google_oauth_client_id" > Client ID< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "google_oauth_client_id" id = "google_oauth_client_id" placeholder = "Google OAuth client ID" data-error = "Please input Client ID" value = "{{ SETTING.get('google_oauth_client_id') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "google_oauth_client_secret" > Client secret< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "google_oauth_client_secret" id = "google_oauth_client_secret" placeholder = "Google OAuth client secret" data-error = "Please input Client secret" value = "{{ SETTING.get('google_oauth_client_secret') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< / fieldset >
< fieldset >
< legend > ADVANCE< / legend >
< div class = "form-group" >
< label for = "google_token_url" > Token URL< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "google_token_url" id = "google_token_url" placeholder = "e.g. https://accounts.google.com/o/oauth2/token" data-error = "Please input token URL" value = "{{ SETTING.get('google_token_url') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "google_token_params" > Token params< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "google_token_params" id = "google_token_params" placeholder = "e.g. {'scope': 'email profile'}" data-error = "Please input token params" value = "{{ SETTING.get('google_token_params') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "google_authorize_url" > Authorize URL< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "google_authorize_url" id = "google_authorize_url" placeholder = "e.g. https://accounts.google.com/o/oauth2/auth" data-error = "Please input Authorize URL" value = "{{ SETTING.get('google_authorize_url') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "google_base_url" > Base URL< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "google_base_url" id = "google_base_url" placeholder = "e.g. https://www.googleapis.com/oauth2/v1/" data-error = "Please input base URL" value = "{{ SETTING.get('google_base_url') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< / fieldset >
< div class = "form-group" >
< button type = "submit" class = "btn btn-flat btn-primary" > Save< / button >
< / div >
< / form >
< / div >
< div class = "col-md-8" >
< legend > Help< / legend >
< p > TBD< / p >
< / div >
< / div >
< / div >
< div class = "tab-pane" id = "tabs-github" >
< div class = "row" >
< div class = "col-md-4" >
2018-08-19 15:08:14 +00:00
< form role = "form" method = "post" data-toggle = "validator" >
2018-08-18 11:41:59 +00:00
< input type = "hidden" value = "github" name = "config_tab" / >
< fieldset >
< legend > GENERAL< / legend >
< div class = "form-group" >
< input type = "checkbox" id = "github_oauth_enabled" name = "github_oauth_enabled" class = "checkbox" { % if SETTING . get ( ' github_oauth_enabled ' ) % } checked { % endif % } >
< label for = "github_oauth_enabled" > Enable Github OAuth< / label >
< / div >
< div class = "form-group" >
< label for = "github_oauth_key" > Client key< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "github_oauth_key" id = "github_oauth_key" placeholder = "Google OAuth client ID" data-error = "Please input Client key" value = "{{ SETTING.get('github_oauth_key') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "github_oauth_secret" > Client secret< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "github_oauth_secret" id = "github_oauth_secret" placeholder = "Google OAuth client secret" data-error = "Please input Client secret" value = "{{ SETTING.get('github_oauth_secret') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< / fieldset >
< fieldset >
< legend > ADVANCE< / legend >
< div class = "form-group" >
< label for = "github_oauth_scope" > Scope< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "github_oauth_scope" id = "github_oauth_scope" placeholder = "e.g. email" data-error = "Please input scope" value = "{{ SETTING.get('github_oauth_scope') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "github_oauth_api_url" > API URL< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "github_oauth_api_url" id = "github_oauth_api_url" placeholder = "e.g. https://api.github.com/user" data-error = "Please input API URL" value = "{{ SETTING.get('github_oauth_api_url') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "github_oauth_token_url" > Token URL< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" name = "github_oauth_token_url" id = "github_oauth_token_url" placeholder = "e.g. https://github.com/login/oauth/access_token" data-error = "Please input Token URL" value = "{{ SETTING.get('github_oauth_token_url') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< div class = "form-group" >
< label for = "github_oauth_authorize_url" > Authorize URL< / label >
2018-08-19 15:08:14 +00:00
< input type = "text" class = "form-control" 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" value = "{{ SETTING.get('github_oauth_authorize_url') }}" >
< span class = "help-block with-errors" > < / span >
2018-08-18 11:41:59 +00:00
< / div >
< / fieldset >
< div class = "form-group" >
< button type = "submit" class = "btn btn-flat btn-primary" > Save< / button >
< / div >
< / form >
< / div >
< div class = "col-md-8" >
< legend > Help< / legend >
< p > TBD< / p >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / div >
< / section >
{% endblock %}
{% block extrascripts %}
2018-08-19 15:08:14 +00:00
{% assets "js_validation" -%}
< script type = "text/javascript" src = "{{ ASSET_URL }}" > < / script >
{%- endassets %}
2018-08-18 11:41:59 +00:00
< script >
$(function() {
$('#tabs').tabs({
// add url anchor tags
activate: function(event, ui) {
window.location.hash = ui.newPanel.attr('id');
}
});
// re-set active tab (ui)
var activeTabIdx = $('#tabs').tabs('option','active');
$('#tabs li:eq('+activeTabIdx+')').tab('show')
});
2018-08-19 15:08:14 +00:00
// START: General tab js
$('#local_db_enabled').iCheck({
checkboxClass : 'icheckbox_square-blue',
increaseArea : '20%'
})
$('#signup_enabled').iCheck({
2018-08-18 11:41:59 +00:00
checkboxClass : 'icheckbox_square-blue',
increaseArea : '20%'
2018-08-19 15:08:14 +00:00
})
// END: General tab js
// START: LDAP tab js
// update validation requirement when checkbox is togged
$('#ldap_enabled').iCheck({
checkboxClass : 'icheckbox_square-blue',
increaseArea : '20%'
}).on('ifChanged', function(e) {
var is_enabled = e.currentTarget.checked;
if (is_enabled){
$('#ldap_uri').prop('required', true);
$('#ldap_base_dn').prop('required', true);
$('#ldap_admin_username').prop('required', true);
$('#ldap_admin_password').prop('required', true);
$('#ldap_filter_basic').prop('required', true);
$('#ldap_filter_username').prop('required', true);
if ($('#ldap_sg_on').is(":checked")) {
$('#ldap_admin_group').prop('required', true);
$('#ldap_user_group').prop('required', true);
}
} else {
$('#ldap_uri').prop('required', false);
$('#ldap_base_dn').prop('required', false);
$('#ldap_admin_username').prop('required', false);
$('#ldap_admin_password').prop('required', false);
$('#ldap_filter_basic').prop('required', false);
$('#ldap_filter_username').prop('required', false);
if ($('#ldap_sg_on').is(":checked")) {
$('#ldap_admin_group').prop('required', false);
$('#ldap_user_group').prop('required', false);
}
}
2018-08-18 11:41:59 +00:00
});
2018-08-19 15:08:14 +00:00
$("input[name='ldap_sg_enabled']" ).change(function(){
if ($('#ldap_sg_on').is(":checked") & & $('#ldap_enabled').is(":checked")) {
$('#ldap_admin_group').prop('required', true);
$('#ldap_user_group').prop('required', true);
} else {
$('#ldap_admin_group').prop('required', false);
$('#ldap_user_group').prop('required', false);
}
});
// init validation reqirement at first time page load
{% if SETTING.get('ldap_enabled') %}
$('#ldap_uri').prop('required', true);
$('#ldap_base_dn').prop('required', true);
$('#ldap_admin_username').prop('required', true);
$('#ldap_admin_password').prop('required', true);
$('#ldap_filter_basic').prop('required', true);
$('#ldap_filter_username').prop('required', true);
if ($('#ldap_sg_on').is(":checked")) {
$('#ldap_admin_group').prop('required', true);
$('#ldap_user_group').prop('required', true);
}
{% endif %}
// END: LDAP tab js
// START: Google tab js
// update validation requirement when checkbox is togged
$('#google_oauth_enabled').iCheck({
checkboxClass : 'icheckbox_square-blue',
increaseArea : '20%'
}).on('ifChanged', function(e) {
var is_enabled = e.currentTarget.checked;
if (is_enabled){
$('#google_oauth_client_id').prop('required', true);
$('#google_oauth_client_secret').prop('required', true);
$('#google_token_url').prop('required', true);
$('#google_token_params').prop('required', true);
$('#google_authorize_url').prop('required', true);
$('#google_base_url').prop('required', true);
} else {
$('#google_oauth_client_id').prop('required', false);
$('#google_oauth_client_secret').prop('required', false);
$('#google_token_url').prop('required', false);
$('#google_token_params').prop('required', false);
$('#google_authorize_url').prop('required', false);
$('#google_base_url').prop('required', false);
}
});
// init validation reqirement at first time page load
{% if SETTING.get('google_oauth_enabled') %}
$('#google_oauth_client_id').prop('required', true);
$('#google_oauth_client_secret').prop('required', true);
$('#google_token_url').prop('required', true);
$('#google_token_params').prop('required', true);
$('#google_authorize_url').prop('required', true);
$('#google_base_url').prop('required', true);
{% endif %}
// END: Google tab js
// START: Github tab js
// update validation requirement when checkbox is togged
$('#github_oauth_enabled').iCheck({
checkboxClass : 'icheckbox_square-blue',
increaseArea : '20%'
}).on('ifChanged', function(e) {
var is_enabled = e.currentTarget.checked;
if (is_enabled){
$('#github_oauth_key').prop('required', true);
$('#github_oauth_secret').prop('required', true);
$('#github_oauth_scope').prop('required', true);
$('#github_oauth_api_url').prop('required', true);
$('#github_oauth_token_url').prop('required', true);
$('#github_oauth_authorize_url').prop('required', true);
} else {
$('#github_oauth_key').prop('required', false);
$('#github_oauth_secret').prop('required', false);
$('#github_oauth_scope').prop('required', false);
$('#github_oauth_api_url').prop('required', false);
$('#github_oauth_token_url').prop('required', false);
$('#github_oauth_authorize_url').prop('required', false);
}
});
// init validation reqirement at first time page load
{% if SETTING.get('google_oauth_enabled') %}
$('#github_oauth_key').prop('required', true);
$('#github_oauth_secret').prop('required', true);
$('#github_oauth_scope').prop('required', true);
$('#github_oauth_api_url').prop('required', true);
$('#github_oauth_token_url').prop('required', true);
$('#github_oauth_authorize_url').prop('required', true);
{% endif %}
// END: Github tab js
2018-08-18 11:41:59 +00:00
< / script >
{% endblock %}