2019-01-30 16:18:44 +01:00
< ? php
2010-08-10 11:01:06 +02:00
// Pandora FMS - http://pandorafms.com
// ==================================================
// Copyright (c) 2005-2010 Artica Soluciones Tecnologicas
// Please see http://pandorafms.org for full contribution list
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation for version 2.
// This program is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
2015-08-13 10:58:23 +02:00
// Warning: This file may be required into the metaconsole's setup
2010-08-10 11:01:06 +02:00
// Load global vars
global $config ;
2019-01-30 16:18:44 +01:00
check_login ();
2010-08-10 11:01:06 +02:00
2019-01-30 16:18:44 +01:00
if ( ! check_acl ( $config [ 'id_user' ], 0 , 'PM' ) && ! is_user_admin ( $config [ 'id_user' ])) {
db_pandora_audit ( 'ACL Violation' , 'Trying to access Setup Management' );
include 'general/noaccess.php' ;
return ;
2010-08-10 11:01:06 +02:00
}
// Load enterprise extensions
2019-01-30 16:18:44 +01:00
enterprise_include ( 'godmode/setup/setup_auth.php' );
if ( is_ajax ()) {
$change_auth_metod = ( bool ) get_parameter ( 'change_auth_metod' );
if ( $change_auth_metod ) {
$table = new StdClass ();
$table -> data = [];
$table -> width = '100%' ;
$table -> class = 'databox filters table_result_auth' ;
$table -> size [ 'name' ] = '30%' ;
$table -> style [ 'name' ] = 'font-weight: bold' ;
$type_auth = ( string ) get_parameter ( 'type_auth' , '' );
// field for all types except mysql
if ( $type_auth != 'mysql' ) {
// Fallback to local authentication
$row = [];
$row [ 'name' ] = __ ( 'Fallback to local authentication' ) . ui_print_help_tip ( __ ( 'Enable this option if you want to fallback to local authentication when remote (ldap etc...) authentication failed.' ), true );
2019-02-26 12:04:18 +01:00
$row [ 'control' ] = html_print_checkbox_switch ( 'fallback_local_auth' , 1 , $config [ 'fallback_local_auth' ], true );
2019-01-30 16:18:44 +01:00
$table -> data [ 'fallback_local_auth' ] = $row ;
if ( enterprise_installed ()) {
// Autocreate remote users
$row = [];
$row [ 'name' ] = __ ( 'Autocreate remote users' );
2019-02-26 12:04:18 +01:00
$row [ 'control' ] = html_print_checkbox_switch_extended ( 'autocreate_remote_users' , 1 , $config [ 'autocreate_remote_users' ], false , '' , '' , true ) . ' ' ;
2019-01-30 16:18:44 +01:00
$table -> data [ 'autocreate_remote_users' ] = $row ;
add_enterprise_auth_autocreate_profiles ( $table , $type_auth );
}
}
switch ( $type_auth ) {
case 'mysql' :
break ;
case 'ldap' :
// LDAP server
$row = [];
$row [ 'name' ] = __ ( 'LDAP server' );
$row [ 'control' ] = html_print_input_text ( 'ldap_server' , $config [ 'ldap_server' ], '' , 30 , 100 , true );
$table -> data [ 'ldap_server' ] = $row ;
// LDAP port
$row = [];
$row [ 'name' ] = __ ( 'LDAP port' );
$row [ 'control' ] = html_print_input_text ( 'ldap_port' , $config [ 'ldap_port' ], '' , 10 , 100 , true );
$table -> data [ 'ldap_port' ] = $row ;
// LDAP version
$ldap_versions = [
1 => 'LDAPv1' ,
2 => 'LDAPv2' ,
3 => 'LDAPv3' ,
];
$row = [];
$row [ 'name' ] = __ ( 'LDAP version' );
$row [ 'control' ] = html_print_select ( $ldap_versions , 'ldap_version' , $config [ 'ldap_version' ], '' , '' , 0 , true );
$table -> data [ 'ldap_version' ] = $row ;
// Start TLS
$row = [];
$row [ 'name' ] = __ ( 'Start TLS' );
2019-02-26 12:04:18 +01:00
$row [ 'control' ] = html_print_checkbox_switch ( 'ldap_start_tls' , 1 , $config [ 'ldap_start_tls' ], true );
2019-01-30 16:18:44 +01:00
$table -> data [ 'ldap_start_tls' ] = $row ;
// Base DN
$row = [];
$row [ 'name' ] = __ ( 'Base DN' );
$row [ 'control' ] = html_print_input_text ( 'ldap_base_dn' , $config [ 'ldap_base_dn' ], '' , 60 , 100 , true );
$table -> data [ 'ldap_base_dn' ] = $row ;
// Login attribute
$row = [];
$row [ 'name' ] = __ ( 'Login attribute' );
$row [ 'control' ] = html_print_input_text ( 'ldap_login_attr' , $config [ 'ldap_login_attr' ], '' , 60 , 100 , true );
$table -> data [ 'ldap_login_attr' ] = $row ;
// Admin LDAP login
$row = [];
$row [ 'name' ] = __ ( 'Admin LDAP login' );
$row [ 'control' ] = html_print_input_text ( 'ldap_admin_login' , $config [ 'ldap_admin_login' ], '' , 60 , 100 , true );
$table -> data [ 'ldap_admin_login' ] = $row ;
// Admin LDAP password
$row = [];
$row [ 'name' ] = __ ( 'Admin LDAP password' );
$row [ 'control' ] = html_print_input_password ( 'ldap_admin_pass' , $config [ 'ldap_admin_pass' ], $alt = '' , 60 , 100 , true );
$table -> data [ 'ldap_admin_pass' ] = $row ;
break ;
case 'pandora' :
case 'ad' :
case 'saml' :
case 'integria' :
// Add enterprise authentication options
if ( enterprise_installed ()) {
add_enterprise_auth_options ( $table , $type_auth );
}
break ;
}
// field for all types
// Enable double authentication
// Set default value
set_unless_defined ( $config [ 'double_auth_enabled' ], false );
$row = [];
$row [ 'name' ] = __ ( 'Double authentication' ) . ui_print_help_tip ( __ ( 'If this option is enabled, the users can use double authentication with their accounts' ), true );
2019-02-19 13:13:13 +01:00
$row [ 'control' ] = html_print_input_hidden ( 'double_auth_enabled' , 0 );
2019-02-26 12:04:18 +01:00
$row [ 'control' ] .= html_print_checkbox_switch ( 'double_auth_enabled' , 1 , $config [ 'double_auth_enabled' ], true );
2019-01-30 16:18:44 +01:00
$table -> data [ 'double_auth_enabled' ] = $row ;
// Session timeout
// Default session timeout
set_when_empty ( $config [ 'session_timeout' ], 90 );
$row = [];
$row [ 'name' ] = __ ( 'Session timeout (mins)' ) . ui_print_help_tip ( __ ( 'This is defined in minutes, If you wish a permanent session should putting -1 in this field.' ), true );
$row [ 'control' ] = html_print_input_text ( 'session_timeout' , $config [ 'session_timeout' ], '' , 10 , 10 , true );
$table -> data [ 'session_timeout' ] = $row ;
html_print_table ( $table );
return ;
}
2016-11-04 14:10:07 +01:00
}
2019-01-30 16:18:44 +01:00
require_once $config [ 'homedir' ] . '/include/functions_profile.php' ;
2016-11-04 14:10:07 +01:00
2015-06-25 10:07:53 +02:00
$table = new StdClass ();
2019-01-30 16:18:44 +01:00
$table -> data = [];
2015-06-25 10:07:53 +02:00
$table -> width = '100%' ;
2015-06-26 11:20:08 +02:00
$table -> class = 'databox filters' ;
2015-08-13 10:58:23 +02:00
$table -> size [ 'name' ] = '30%' ;
2019-01-30 16:18:44 +01:00
$table -> style [ 'name' ] = 'font-weight: bold' ;
2015-08-13 10:58:23 +02:00
// Auth methods added to the table (doesn't take in account mysql)
2019-01-30 16:18:44 +01:00
$auth_methods_added = [];
2015-08-13 10:58:23 +02:00
// Remote options row names
// Fill this array for every matched row
2019-01-30 16:18:44 +01:00
$remote_rows = [];
2015-08-13 10:58:23 +02:00
// Autocreate options row names
// Fill this array for every matched row
2019-01-30 16:18:44 +01:00
$autocreate_rows = [];
$no_autocreate_rows = [];
2010-08-10 11:01:06 +02:00
2015-08-13 10:58:23 +02:00
// LDAP data row names
// Fill this array for every matched row
2019-01-30 16:18:44 +01:00
$ldap_rows = [];
2015-08-13 10:58:23 +02:00
// Method
2019-01-30 16:18:44 +01:00
$auth_methods = [
'mysql' => __ ( 'Local %s' , get_product_name ()),
'ldap' => __ ( 'ldap' ),
];
2013-08-07 10:26:26 +02:00
if ( enterprise_installed ()) {
2019-01-30 16:18:44 +01:00
add_enterprise_auth_methods ( $auth_methods );
2013-08-07 10:26:26 +02:00
}
2016-11-04 14:10:07 +01:00
2019-01-30 16:18:44 +01:00
$row = [];
2015-08-13 10:58:23 +02:00
$row [ 'name' ] = __ ( 'Authentication method' );
$row [ 'control' ] = html_print_select ( $auth_methods , 'auth' , $config [ 'auth' ], '' , '' , 0 , true );
$table -> data [ 'auth' ] = $row ;
// Form
2010-08-10 11:01:06 +02:00
echo '<form id="form_setup" method="post">' ;
2015-08-13 10:58:23 +02:00
if ( ! is_metaconsole ()) {
2019-01-30 16:18:44 +01:00
html_print_input_hidden ( 'update_config' , 1 );
} else {
// To use it in the metasetup
html_print_input_hidden ( 'action' , 'save' );
html_print_input_hidden ( 'hash_save_config' , md5 ( 'save' . $config [ 'dbpass' ]));
2015-08-13 10:58:23 +02:00
}
2019-01-30 16:18:44 +01:00
html_print_table ( $table );
2016-11-04 14:10:07 +01:00
echo '<div id="table_auth_result"></div>' ;
2010-08-10 11:01:06 +02:00
echo '<div class="action-buttons" style="width: ' . $table -> width . '">' ;
2019-01-30 16:18:44 +01:00
html_print_submit_button ( __ ( 'Update' ), 'update_button' , false , 'class="sub upd"' );
2010-08-10 11:01:06 +02:00
echo '</div>' ;
echo '</form>' ;
?>
< script type = " text/javascript " >
2019-01-30 16:18:44 +01:00
$ ( '#auth' ) . on ( 'change' , function (){
type_auth = $ ( '#auth' ) . val ();
$ . ajax ({
type : " POST " ,
url : " <?php echo ui_get_full_url('ajax.php', false, false, false); ?> " ,
data : " page=godmode/setup/setup_auth&change_auth_metod=1&type_auth= " + type_auth ,
dataType : " html " ,
success : function ( data ) {
$ ( '.table_result_auth' ) . remove ();
$ ( '#table_auth_result' ) . append ( data );
}
});
}) . change ();
2010-08-10 11:01:06 +02:00
</ script >