version 1.160.6.118.2.4, 2022/02/07 11:59:29
|
version 1.160.6.118.2.5, 2022/02/21 05:31:41
|
Line 218 sub handler {
|
Line 218 sub handler {
|
'serverstatuses','requestcourses','helpsettings', |
'serverstatuses','requestcourses','helpsettings', |
'coursedefaults','usersessions','loadbalancing', |
'coursedefaults','usersessions','loadbalancing', |
'requestauthor','selfenrollment','inststatus', |
'requestauthor','selfenrollment','inststatus', |
'passwords','ltitools','wafproxy','ipaccess'],$dom); |
'passwords','ltitools','ltisec','wafproxy','ipaccess'],$dom); |
if (ref($domconfig{'ltitools'}) eq 'HASH') { |
if (ref($domconfig{'ltitools'}) eq 'HASH') { |
my %encconfig = |
my %encconfig = |
&Apache::lonnet::get_dom('encconfig',['ltitools'],$dom,undef,1); |
&Apache::lonnet::get_dom('encconfig',['ltitools','linkprot'],$dom,undef,1); |
if (ref($encconfig{'ltitools'}) eq 'HASH') { |
if (ref($encconfig{'ltitools'}) eq 'HASH') { |
foreach my $id (keys(%{$domconfig{'ltitools'}})) { |
foreach my $id (keys(%{$domconfig{'ltitools'}})) { |
if (ref($domconfig{'ltitools'}{$id}) eq 'HASH') { |
if (ref($domconfig{'ltitools'}{$id}) eq 'HASH') { |
Line 232 sub handler {
|
Line 232 sub handler {
|
} |
} |
} |
} |
} |
} |
|
if (ref($domconfig{'ltisec'}) eq 'HASH') { |
|
if (ref($domconfig{'ltisec'}{'linkprot'}) eq 'HASH') { |
|
if (ref($encconfig{'linkprot'}) eq 'HASH') { |
|
foreach my $id (keys(%{$domconfig{'ltisec'}{'linkprot'}})) { |
|
unless ($id =~ /^\d+$/) { |
|
delete($domconfig{'ltisec'}{'linkprot'}{$id}); |
|
} |
|
if ((ref($domconfig{'ltisec'}{'linkprot'}{$id}) eq 'HASH') && |
|
(ref($encconfig{'linkprot'}{$id}) eq 'HASH')) { |
|
foreach my $item ('key','secret') { |
|
$domconfig{'ltisec'}{'linkprot'}{$id}{$item} = $encconfig{'linkprot'}{$id}{$item}; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
my @prefs_order = ('rolecolors','login','ipaccess','defaults','wafproxy','passwords', |
my @prefs_order = ('rolecolors','login','ipaccess','defaults','wafproxy','passwords', |
'quotas','autoenroll','autoupdate','autocreate','directorysrch', |
'quotas','autoenroll','autoupdate','autocreate','directorysrch', |
'contacts','usercreation','selfcreation','usermodification', |
'contacts','usercreation','selfcreation','usermodification', |
'scantron','requestcourses','requestauthor','coursecategories', |
'scantron','requestcourses','requestauthor','coursecategories', |
'serverstatuses','helpsettings','coursedefaults', |
'serverstatuses','helpsettings','coursedefaults', |
'ltitools','selfenrollment','usersessions'); |
'ltitools','selfenrollment','usersessions','lti'); |
my %existing; |
my %existing; |
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
if (ref($domconfig{'loadbalancing'}) eq 'HASH') { |
%existing = %{$domconfig{'loadbalancing'}}; |
%existing = %{$domconfig{'loadbalancing'}}; |
Line 527 sub handler {
|
Line 544 sub handler {
|
print => \&print_ltitools, |
print => \&print_ltitools, |
modify => \&modify_ltitools, |
modify => \&modify_ltitools, |
}, |
}, |
|
'lti' => |
|
{text => 'LTI Link Protection and LTI Consumers', |
|
help => 'Domain_Configuration_LTI_Provider', |
|
header => [{col1 => 'Encryption of shared secrets', |
|
col2 => 'Settings'}, |
|
{col1 => 'Rules for shared secrets', |
|
col2 => 'Settings'}, |
|
{col1 => 'Link Protectors', |
|
col2 => 'Settings'},], |
|
print => \&print_lti, |
|
modify => \&modify_lti, |
|
}, |
'ipaccess' => |
'ipaccess' => |
{text => 'IP-based access control', |
{text => 'IP-based access control', |
help => 'Domain_Configuration_IP_Access', |
help => 'Domain_Configuration_IP_Access', |
Line 542 sub handler {
|
Line 571 sub handler {
|
header => [{col1 => 'Log-in Service', |
header => [{col1 => 'Log-in Service', |
col2 => 'Server Setting',}, |
col2 => 'Server Setting',}, |
{col1 => 'Log-in Page Items', |
{col1 => 'Log-in Page Items', |
col2 => ''}, |
col2 => 'Settings'}, |
{col1 => 'Log-in Help', |
{col1 => 'Log-in Help', |
col2 => 'Value'}, |
col2 => 'Value'}, |
{col1 => 'Custom HTML in document head', |
{col1 => 'Custom HTML in document head', |
Line 722 sub process_changes {
|
Line 751 sub process_changes {
|
$output = &modify_usersessions($dom,$lastactref,%domconfig); |
$output = &modify_usersessions($dom,$lastactref,%domconfig); |
} elsif ($action eq 'loadbalancing') { |
} elsif ($action eq 'loadbalancing') { |
$output = &modify_loadbalancing($dom,%domconfig); |
$output = &modify_loadbalancing($dom,%domconfig); |
|
} elsif ($action eq 'lti') { |
|
$output = &modify_lti($r,$dom,$action,$lastactref,%domconfig); |
} elsif ($action eq 'passwords') { |
} elsif ($action eq 'passwords') { |
$output = &modify_passwords($r,$dom,$confname,$lastactref,%domconfig); |
$output = &modify_passwords($r,$dom,$confname,$lastactref,%domconfig); |
} elsif ($action eq 'ltitools') { |
} elsif ($action eq 'ltitools') { |
Line 743 sub print_config_box {
|
Line 774 sub print_config_box {
|
} elsif ($action eq 'defaults') { |
} elsif ($action eq 'defaults') { |
$output = &defaults_javascript($settings); |
$output = &defaults_javascript($settings); |
} elsif ($action eq 'passwords') { |
} elsif ($action eq 'passwords') { |
$output = &passwords_javascript(); |
$output = &passwords_javascript($action); |
} elsif ($action eq 'helpsettings') { |
} elsif ($action eq 'helpsettings') { |
my (%privs,%levelscurrent); |
my (%privs,%levelscurrent); |
my %full=(); |
my %full=(); |
Line 762 sub print_config_box {
|
Line 793 sub print_config_box {
|
\@templateroles); |
\@templateroles); |
} elsif ($action eq 'ltitools') { |
} elsif ($action eq 'ltitools') { |
$output .= <itools_javascript($settings); |
$output .= <itools_javascript($settings); |
|
} elsif ($action eq 'lti') { |
|
$output .= &passwords_javascript('secrets')."\n". |
|
<i_javascript($dom,$settings); |
} elsif ($action eq 'wafproxy') { |
} elsif ($action eq 'wafproxy') { |
$output .= &wafproxy_javascript($dom); |
$output .= &wafproxy_javascript($dom); |
} elsif ($action eq 'autoupdate') { |
} elsif ($action eq 'autoupdate') { |
Line 812 sub print_config_box {
|
Line 846 sub print_config_box {
|
if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || |
if (($action eq 'autoupdate') || ($action eq 'usercreation') || ($action eq 'selfcreation') || |
($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') || |
($action eq 'usermodification') || ($action eq 'defaults') || ($action eq 'coursedefaults') || |
($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') || |
($action eq 'selfenrollment') || ($action eq 'usersessions') || ($action eq 'directorysrch') || |
($action eq 'helpsettings') || ($action eq 'contacts') || ($action eq 'wafproxy')) { |
($action eq 'helpsettings') || ($action eq 'contacts') || ($action eq 'wafproxy') || ($action eq 'lti')) { |
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal); |
$output .= $item->{'print'}->('top',$dom,$settings,\$rowtotal); |
} elsif ($action eq 'passwords') { |
} elsif ($action eq 'passwords') { |
$output .= $item->{'print'}->('top',$dom,$confname,$settings,\$rowtotal); |
$output .= $item->{'print'}->('top',$dom,$confname,$settings,\$rowtotal); |
Line 847 sub print_config_box {
|
Line 881 sub print_config_box {
|
if (($action eq 'autoupdate') || ($action eq 'usercreation') || |
if (($action eq 'autoupdate') || ($action eq 'usercreation') || |
($action eq 'selfcreation') || ($action eq 'selfenrollment') || |
($action eq 'selfcreation') || ($action eq 'selfenrollment') || |
($action eq 'usersessions') || ($action eq 'coursecategories') || |
($action eq 'usersessions') || ($action eq 'coursecategories') || |
($action eq 'contacts') || ($action eq 'passwords')) { |
($action eq 'contacts') || ($action eq 'passwords') || ($action eq 'lti')) { |
if ($action eq 'coursecategories') { |
if ($action eq 'coursecategories') { |
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal); |
$output .= &print_coursecategories('middle',$dom,$item,$settings,\$rowtotal); |
$colspan = ' colspan="2"'; |
$colspan = ' colspan="2"'; |
Line 3098 function toggleWAF() {
|
Line 3132 function toggleWAF() {
|
ENDSCRIPT |
ENDSCRIPT |
} |
} |
|
|
|
sub lti_javascript { |
|
my ($dom,$settings) = @_; |
|
my $togglejs = <i_toggle_js($dom); |
|
my $linkprot_js = &Apache::courseprefs::linkprot_javascript(); |
|
return <<"ENDSCRIPT"; |
|
<script type="text/javascript"> |
|
// <![CDATA[ |
|
|
|
$linkprot_js |
|
|
|
// ]]> |
|
</script> |
|
|
|
$togglejs |
|
|
|
ENDSCRIPT |
|
} |
|
|
|
sub lti_toggle_js { |
|
my ($dom) = @_; |
|
my %servers = &Apache::lonnet::get_servers($dom,'library'); |
|
my $primary = &Apache::lonnet::domain($dom,'primary'); |
|
my $course_servers = "'".join("','",keys(%servers))."'"; |
|
function toggleLTIEncKey(form) { |
|
var shownhosts = new Array(); |
|
var hiddenhosts = new Array(); |
|
var forcourse = new Array($course_servers); |
|
var fromdomain = '$primary'; |
|
var crsradio = form.elements['ltisec_crslinkprot']; |
|
if (crsradio.length) { |
|
for (var i=0; i<crsradio.length; i++) { |
|
if (crsradio[i].checked) { |
|
if (crsradio[i].value == 1) { |
|
if (forcourse.length > 0) { |
|
for (var j=0; j<forcourse.length; j++) { |
|
if (!shownhosts.includes(forcourse[j])) { |
|
shownhosts.push(forcourse[j]); |
|
} |
|
} |
|
} |
|
} else { |
|
if (forcourse.length > 0) { |
|
for (var j=0; j<forcourse.length; j++) { |
|
if (!hiddenhosts.includes(forcourse[j])) { |
|
hiddenhosts.push(forcourse[j]); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
} |
|
var domradio = form.elements['ltisec_domlinkprot']; |
|
if (domradio.length) { |
|
for (var i=0; i<domradio.length; i++) { |
|
if (domradio[i].checked) { |
|
if (domradio[i].value == 1) { |
|
if (!shownhosts.includes(fromdomain)) { |
|
shownhosts.push(fromdomain); |
|
} |
|
} else { |
|
if (!hiddenhosts.includes(fromdomain)) { |
|
hiddenhosts.push(fromdomain); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if (shownhosts.length > 0) { |
|
for (var i=0; i<shownhosts.length; i++) { |
|
if (document.getElementById('ltisec_info_'+shownhosts[i])) { |
|
document.getElementById('ltisec_info_'+shownhosts[i]).style.display = 'block'; |
|
} |
|
} |
|
if (document.getElementById('ltisec_noprivkey')) { |
|
document.getElementById('ltisec_noprivkey').style.display = 'none'; |
|
} |
|
} else { |
|
if (document.getElementById('ltisec_noprivkey')) { |
|
document.getElementById('ltisec_noprivkey').style.display = 'inline-block'; |
|
} |
|
} |
|
if (hiddenhosts.length > 0) { |
|
for (var i=0; i<hiddenhosts.length; i++) { |
|
if (!shownhosts.includes(hiddenhosts[i])) { |
|
if (document.getElementById('ltisec_info_'+hiddenhosts[i])) { |
|
document.getElementById('ltisec_info_'+hiddenhosts[i]).style.display = 'none'; |
|
} |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
|
function togglePrivKey(form,hostid) { |
|
var radioname = ''; |
|
var currdivid = ''; |
|
var newdivid = ''; |
|
if ((document.getElementById('ltisec_divcurrprivkey_'+hostid)) && |
|
(document.getElementById('ltisec_divchgprivkey_'+hostid))) { |
|
currdivid = document.getElementById('ltisec_divcurrprivkey_'+hostid); |
|
newdivid = document.getElementById('ltisec_divchgprivkey_'+hostid); |
|
radioname = form.elements['ltisec_changeprivkey_'+hostid]; |
|
if (radioname) { |
|
if (radioname.length > 0) { |
|
var setvis; |
|
for (var i=0; i<radioname.length; i++) { |
|
if (radioname[i].checked == true) { |
|
if (radioname[i].value == 1) { |
|
newdivid.style.display = 'inline-block'; |
|
currdivid.style.display = 'none'; |
|
setvis = 1; |
|
} |
|
break; |
|
} |
|
} |
|
if (!setvis) { |
|
newdivid.style.display = 'none'; |
|
currdivid.style.display = 'inline-block'; |
|
} |
|
} |
|
} |
|
} |
|
} |
|
|
|
// ]]> |
|
</script> |
|
|
|
ENDSCRIPT |
|
} |
|
|
sub autoupdate_javascript { |
sub autoupdate_javascript { |
return <<"ENDSCRIPT"; |
return <<"ENDSCRIPT"; |
<script type="text/javascript"> |
<script type="text/javascript"> |
Line 5048 sub ltitools_names {
|
Line 5213 sub ltitools_names {
|
return %lt; |
return %lt; |
} |
} |
|
|
|
sub print_lti { |
|
my ($position,$dom,$settings,$rowtotal) = @_; |
|
my $itemcount = 1; |
|
my ($datatable,$css_class); |
|
my (%rules,%encrypt,%privkeys,%linkprot); |
|
if (ref($settings) eq 'HASH') { |
|
if ($position eq 'top') { |
|
if (exists($settings->{'encrypt'})) { |
|
if (ref($settings->{'encrypt'}) eq 'HASH') { |
|
foreach my $key (keys(%{$settings->{'encrypt'}})) { |
|
$encrypt{'ltisec_'.$key.'linkprot'} = $settings->{'encrypt'}{$key}; |
|
} |
|
} |
|
} |
|
if (exists($settings->{'private'})) { |
|
if (ref($settings->{'private'}) eq 'HASH') { |
|
if (ref($settings->{'private'}) eq 'HASH') { |
|
if (ref($settings->{'private'}{'keys'}) eq 'ARRAY') { |
|
map { $privkeys{$_} = 1; } (@{$settings->{'private'}{'keys'}}); |
|
} |
|
} |
|
} |
|
} |
|
} elsif ($position eq 'middle') { |
|
if (exists($settings->{'rules'})) { |
|
if (ref($settings->{'rules'}) eq 'HASH') { |
|
%rules = %{$settings->{'rules'}}; |
|
} |
|
} |
|
} elsif ($position eq 'bottom') { |
|
if (exists($settings->{'linkprot'})) { |
|
if (ref($settings->{'linkprot'}) eq 'HASH') { |
|
%linkprot = %{$settings->{'linkprot'}}; |
|
if ($linkprot{'lock'}) { |
|
delete($linkprot{'lock'}); |
|
} |
|
} |
|
} |
|
} |
|
} |
|
if ($position eq 'top') { |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
my %servers = &Apache::lonnet::get_servers($dom,'library'); |
|
my $primary = &Apache::lonnet::domain($dom,'primary'); |
|
my ($extra,$numshown); |
|
foreach my $hostid (sort(keys(%servers))) { |
|
my ($showextra,$divsty,$switch); |
|
if ($hostid eq $primary) { |
|
if ($encrypt{'ltisec_domlinkprot'}) { |
|
$showextra = 1; |
|
} |
|
} |
|
if ($encrypt{'ltisec_crslinkprot'}) { |
|
$showextra = 1; |
|
} |
|
unless (grep(/^\Q$hostid\E$/,@ids)) { |
|
$switch = 1; |
|
} |
|
if ($showextra) { |
|
$numshown ++; |
|
$divsty = 'display:inline-block'; |
|
} else { |
|
$divsty = 'display:none'; |
|
} |
|
$extra .= '<fieldset id="ltisec_info_'.$hostid.'" style="'.$divsty.'">'. |
|
'<legend>'.$hostid.'</legend>'; |
|
if ($switch) { |
|
my $switchserver = '<a href="/adm/switchserver?otherserver='.$hostid.'&role='. |
|
&HTML::Entities::encode($env{'request.role'},'\'<>"&'). |
|
'&destinationurl=/adm/domainprefs">'.&mt('Switch Server').'</a>'; |
|
if (exists($privkeys{$hostid})) { |
|
$extra .= '<div id="ltisec_divcurrprivkey_'.$hostid.'" style="display:inline-block" />'. |
|
'<span class="LC_nobreak">'. |
|
&mt('Encryption Key').': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'. |
|
'<span class="LC_nobreak">'.&mt('Change?'). |
|
'<label><input type="radio" value="0" name="ltisec_changeprivkey_'.$hostid.'" onclick="javascript:togglePrivKey(this.form,'."'$hostid'".');" checked="checked" />'.&mt('No').'</label>'. |
|
(' 'x2). |
|
'<label><input type="radio" value="1" name="ltisec_changeprivkey_'.$hostid.'" onclick="javascript:togglePrivKey(this.form,'."'$hostid'".');" />'.&mt('Yes'). |
|
'</label> </span><div id="ltisec_divchgprivkey_'.$hostid.'" style="display:none" />'. |
|
'<span class="LC_nobreak"> - '.&mt('submit from server ([_1]): [_2].',$hostid,$switchserver). |
|
'</span></div>'; |
|
} else { |
|
$extra .= '<span class="LC_nobreak">'. |
|
&mt('Key required').' - '.&mt('submit from server ([_1]): [_2].',$hostid,$switchserver). |
|
'</span>'."\n"; |
|
} |
|
} elsif (exists($privkeys{$hostid})) { |
|
$extra .= '<div id="ltisec_divcurrprivkey_'.$hostid.'" style="display:inline-block" /><span class="LC_nobreak">'. |
|
&mt('Encryption Key').': ['.&mt('not shown').'] '.(' 'x2).'</span></div>'. |
|
'<span class="LC_nobreak">'.&mt('Change?'). |
|
'<label><input type="radio" value="0" name="ltisec_changeprivkey_'.$hostid.'" onclick="javascript:togglePrivKey(this.form,'."'$hostid'".');" checked="checked" />'.&mt('No').'</label>'. |
|
(' 'x2). |
|
'<label><input type="radio" value="1" name="ltisec_changeprivkey_'.$hostid.'" onclick="javascript:togglePrivKey(this.form,'."'$hostid'".');" />'.&mt('Yes'). |
|
'</label> </span><div id="ltisec_divchgprivkey_'.$hostid.'" style="display:none" />'. |
|
'<span class="LC_nobreak">'.&mt('New Key').':'. |
|
'<input type="password" size="20" name="ltisec_privkey_'.$hostid.'" value="" autocomplete="off" />'. |
|
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.ltisec_privkey_'.$hostid.'.type='."'text'".' } else { this.form.ltisec_privkey_'.$hostid.'.type='."'password'".' }" />'.&mt('Visible input').'</label>'. |
|
'</span></div>'; |
|
} else { |
|
$extra .= '<span class="LC_nobreak">'.&mt('Encryption Key').':'. |
|
'<input type="password" size="20" name="ltisec_privkey_'.$hostid.'" value="" autocomplete="off" />'. |
|
'<label><input type="checkbox" name="visible" onclick="if (this.checked) { this.form.ltisec_privkey_'.$hostid.'.type='."'text'".' } else { this.form.ltisec_privkey_'.$hostid.'.type='."'password'".' }" />'.&mt('Visible input').'</label>'; |
|
} |
|
$extra .= '</fieldset>'; |
|
} |
|
my %choices = &Apache::lonlocal::texthash ( |
|
ltisec_crslinkprot => 'Encrypt stored link protection secrets defined in courses', |
|
ltisec_domlinkprot => 'Encrypt stored link protection secrets defined in domain', |
|
); |
|
my @toggles = qw(ltisec_crslinkprot ltisec_domlinkprot); |
|
my %defaultchecked = ( |
|
'ltisec_crslinkprot' => 'off', |
|
'ltisec_domlinkprot' => 'off', |
|
); |
|
my ($onclick,$itemcount); |
|
$onclick = 'javascript:toggleLTIEncKey(this.form);'; |
|
($datatable,$itemcount) = &radiobutton_prefs(\%encrypt,\@toggles,\%defaultchecked, |
|
\%choices,$itemcount,$onclick,'','left','no'); |
|
|
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
my $noprivkeysty = 'display:inline-block'; |
|
if ($numshown) { |
|
$noprivkeysty = 'display:none'; |
|
} |
|
$datatable .= '<tr '.$css_class.'><td><span class="LC_nobreak">'.&mt('Encryption Key(s)').'</td>'. |
|
'<td><div id="ltisec_noprivkey" style="'.$noprivkeysty.'" >'. |
|
'<span class="LC_nobreak">'.&mt('Not in use').'</span></div>'. |
|
$extra. |
|
'</td></tr>'; |
|
$itemcount ++; |
|
$$rowtotal += $itemcount; |
|
} elsif ($position eq 'middle') { |
|
$datatable = &password_rules('secrets',\$itemcount,\%rules); |
|
$$rowtotal += $itemcount; |
|
} elsif ($position eq 'bottom') { |
|
$datatable .= &Apache::courseprefs::print_linkprotection($dom,'',$settings,$rowtotal,'','','domain'); |
|
} |
|
return $datatable; |
|
} |
|
|
sub print_coursedefaults { |
sub print_coursedefaults { |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); |
my ($css_class,$datatable,%checkedon,%checkedoff,%defaultchecked,@toggles); |
Line 5063 sub print_coursedefaults {
|
Line 5368 sub print_coursedefaults {
|
postsubmit => 'Disable submit button/keypress following student submission', |
postsubmit => 'Disable submit button/keypress following student submission', |
canclone => "People who may clone a course (besides course's owner and coordinators)", |
canclone => "People who may clone a course (besides course's owner and coordinators)", |
mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver', |
mysqltables => 'Lifetime (s) of "Temporary" MySQL tables (student performance data) on homeserver', |
ltiauth => 'Student username in LTI launch of deep-linked URL can be accepted without re-authentication', |
|
); |
); |
|
ltiauth => 'Student username in LTI launch of deep-linked URL can be accepted without re-authentication', |
my %staticdefaults = ( |
my %staticdefaults = ( |
anonsurvey_threshold => 10, |
anonsurvey_threshold => 10, |
uploadquota => 500, |
uploadquota => 500, |
Line 5861 sub print_passwords {
|
Line 6166 sub print_passwords {
|
$itemcount ++; |
$itemcount ++; |
} |
} |
} elsif ($position eq 'lower') { |
} elsif ($position eq 'lower') { |
my ($min,$max,%chars,$numsaved); |
$datatable .= &password_rules('passwords',\$itemcount,$settings); |
$min = $Apache::lonnet::passwdmin; |
|
if (ref($settings) eq 'HASH') { |
|
if ($settings->{min}) { |
|
$min = $settings->{min}; |
|
} |
|
if ($settings->{max}) { |
|
$max = $settings->{max}; |
|
} |
|
if (ref($settings->{chars}) eq 'ARRAY') { |
|
map { $chars{$_} = 1; } (@{$settings->{chars}}); |
|
} |
|
if ($settings->{numsaved}) { |
|
$numsaved = $settings->{numsaved}; |
|
} |
|
} |
|
my %rulenames = &Apache::lonlocal::texthash( |
|
uc => 'At least one upper case letter', |
|
lc => 'At least one lower case letter', |
|
num => 'At least one number', |
|
spec => 'At least one non-alphanumeric', |
|
); |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'><td>'.$titles{'min'}.'</td>'. |
|
'<td class="LC_left_item"><span class="LC_nobreak">'. |
|
'<input type="text" name="passwords_min" value="'.$min.'" size="3" '. |
|
'onblur="javascript:warnIntPass(this);" />'. |
|
'<span class="LC_fontsize_small"> '.&mt('(Enter an integer: 7 or larger)').'</span>'. |
|
'</span></td></tr>'; |
|
$itemcount ++; |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'><td>'.$titles{'max'}.'</td>'. |
|
'<td class="LC_left_item"><span class="LC_nobreak">'. |
|
'<input type="text" name="passwords_max" value="'.$max.'" size="3" '. |
|
'onblur="javascript:warnIntPass(this);" />'. |
|
'<span class="LC_fontsize_small"> '.&mt('(Leave blank for no maximum)').'</span>'. |
|
'</span></td></tr>'; |
|
$itemcount ++; |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'><td>'.$titles{'chars'}.'<br />'. |
|
'<span class="LC_nobreak LC_fontsize_small">'.&mt('(Leave unchecked if not required)'). |
|
'</span></td>'; |
|
my $numinrow = 2; |
|
my @possrules = ('uc','lc','num','spec'); |
|
$datatable .= '<td class="LC_left_item"><table>'; |
|
for (my $i=0; $i<@possrules; $i++) { |
|
my ($rem,$checked); |
|
if ($chars{$possrules[$i]}) { |
|
$checked = ' checked="checked"'; |
|
} |
|
$rem = $i%($numinrow); |
|
if ($rem == 0) { |
|
if ($i > 0) { |
|
$datatable .= '</tr>'; |
|
} |
|
$datatable .= '<tr>'; |
|
} |
|
$datatable .= '<td><span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="passwords_chars" value="'.$possrules[$i].'"'.$checked.' />'. |
|
$rulenames{$possrules[$i]}.'</label></span></td>'; |
|
} |
|
my $rem = @possrules%($numinrow); |
|
my $colsleft = $numinrow - $rem; |
|
if ($colsleft > 1 ) { |
|
$datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">'. |
|
' </td>'; |
|
} elsif ($colsleft == 1) { |
|
$datatable .= '<td class="LC_left_item"> </td>'; |
|
} |
|
$datatable .='</table></td></tr>'; |
|
$itemcount ++; |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'><td>'.$titles{'numsaved'}.'</td>'. |
|
'<td class="LC_left_item"><span class="LC_nobreak">'. |
|
'<input type="text" name="passwords_numsaved" value="'.$numsaved.'" size="3" '. |
|
'onblur="javascript:warnIntPass(this);" />'. |
|
'<span class="LC_fontsize_small"> '.&mt('(Leave blank to not save previous passwords)').'</span>'. |
|
'</span></td></tr>'; |
|
} else { |
} else { |
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); |
my ($othertitle,$usertypes,$types) = &Apache::loncommon::sorted_inst_types($dom); |
my %ownerchg = ( |
my %ownerchg = ( |
Line 5998 sub print_passwords {
|
Line 6226 sub print_passwords {
|
return $datatable; |
return $datatable; |
} |
} |
|
|
|
sub password_rules { |
|
my ($prefix,$itemcountref,$settings) = @_; |
|
my ($min,$max,%chars,$numsaved,$numinrow); |
|
my %titles; |
|
if ($prefix eq 'passwords') { |
|
%titles = &Apache::lonlocal::texthash ( |
|
min => 'Minimum password length', |
|
max => 'Maximum password length', |
|
chars => 'Required characters', |
|
); |
|
} elsif ($prefix eq 'secrets') { |
|
%titles = &Apache::lonlocal::texthash ( |
|
min => 'Minimum secret length', |
|
max => 'Maximum secret length', |
|
chars => 'Required characters', |
|
); |
|
} |
|
$min = $Apache::lonnet::passwdmin; |
|
my $datatable; |
|
my $itemcount; |
|
if (ref($itemcountref)) { |
|
$itemcount = $$itemcountref; |
|
} |
|
if (ref($settings) eq 'HASH') { |
|
if ($settings->{min}) { |
|
$min = $settings->{min}; |
|
} |
|
if ($settings->{max}) { |
|
$max = $settings->{max}; |
|
} |
|
if (ref($settings->{chars}) eq 'ARRAY') { |
|
map { $chars{$_} = 1; } (@{$settings->{chars}}); |
|
} |
|
if ($prefix eq 'passwords') { |
|
if ($settings->{numsaved}) { |
|
$numsaved = $settings->{numsaved}; |
|
} |
|
} |
|
} |
|
my %rulenames = &Apache::lonlocal::texthash( |
|
uc => 'At least one upper case letter', |
|
lc => 'At least one lower case letter', |
|
num => 'At least one number', |
|
spec => 'At least one non-alphanumeric', |
|
); |
|
my $css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'><td>'.$titles{'min'}.'</td>'. |
|
'<td class="LC_left_item"><span class="LC_nobreak">'. |
|
'<input type="text" name="'.$prefix.'_min" value="'.$min.'" size="3" '. |
|
'onblur="javascript:warnInt'.$prefix.'(this);" />'. |
|
'<span class="LC_fontsize_small"> '.&mt('(Enter an integer: 7 or larger)').'</span>'. |
|
'</span></td></tr>'; |
|
$itemcount ++; |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'><td>'.$titles{'max'}.'</td>'. |
|
'<td class="LC_left_item"><span class="LC_nobreak">'. |
|
'<input type="text" name="'.$prefix.'_max" value="'.$max.'" size="3" '. |
|
'onblur="javascript:warnInt'.$prefix.'(this);" />'. |
|
'<span class="LC_fontsize_small"> '.&mt('(Leave blank for no maximum)').'</span>'. |
|
'</span></td></tr>'; |
|
$itemcount ++; |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'><td>'.$titles{'chars'}.'<br />'. |
|
'<span class="LC_nobreak LC_fontsize_small">'.&mt('(Leave unchecked if not required)'). |
|
'</span></td>'; |
|
my $numinrow = 2; |
|
my @possrules = ('uc','lc','num','spec'); |
|
$datatable .= '<td class="LC_left_item"><table>'; |
|
for (my $i=0; $i<@possrules; $i++) { |
|
my ($rem,$checked); |
|
if ($chars{$possrules[$i]}) { |
|
$checked = ' checked="checked"'; |
|
} |
|
$rem = $i%($numinrow); |
|
if ($rem == 0) { |
|
if ($i > 0) { |
|
$datatable .= '</tr>'; |
|
} |
|
$datatable .= '<tr>'; |
|
} |
|
$datatable .= '<td><span class="LC_nobreak"><label>'. |
|
'<input type="checkbox" name="'.$prefix.'_chars" value="'.$possrules[$i].'"'.$checked.' />'. |
|
$rulenames{$possrules[$i]}.'</label></span></td>'; |
|
} |
|
my $rem = @possrules%($numinrow); |
|
my $colsleft = $numinrow - $rem; |
|
if ($colsleft > 1 ) { |
|
$datatable .= '<td colspan="'.$colsleft.'" class="LC_left_item">'. |
|
' </td>'; |
|
} elsif ($colsleft == 1) { |
|
$datatable .= '<td class="LC_left_item"> </td>'; |
|
} |
|
$datatable .='</table></td></tr>'; |
|
$itemcount ++; |
|
if ($prefix eq 'passwords') { |
|
$titles{'numsaved'} = &mt('Number of previous passwords to save and disallow reuse'); |
|
$css_class = $itemcount%2?' class="LC_odd_row"':''; |
|
$datatable .= '<tr'.$css_class.'><td>'.$titles{'numsaved'}.'</td>'. |
|
'<td class="LC_left_item"><span class="LC_nobreak">'. |
|
'<input type="text" name="'.$prefix.'_numsaved" value="'.$numsaved.'" size="3" '. |
|
'onblur="javascript:warnInt'.$prefix.'(this);" />'. |
|
'<span class="LC_fontsize_small"> '.&mt('(Leave blank to not save previous passwords)').'</span>'. |
|
'</span></td></tr>'; |
|
$itemcount ++; |
|
} |
|
if (ref($itemcountref)) { |
|
$$itemcountref += $itemcount; |
|
} |
|
return $datatable; |
|
} |
|
|
sub print_wafproxy { |
sub print_wafproxy { |
my ($position,$dom,$settings,$rowtotal) = @_; |
my ($position,$dom,$settings,$rowtotal) = @_; |
my $css_class; |
my $css_class; |
Line 8987 ENDSCRIPT
|
Line 9326 ENDSCRIPT
|
} |
} |
|
|
sub passwords_javascript { |
sub passwords_javascript { |
my %intalert = &Apache::lonlocal::texthash ( |
my ($prefix) = @_; |
authcheck => 'Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.', |
my %intalert; |
authcost => 'Warning: bcrypt encryption cost for internal authentication must be an integer.', |
if ($prefix eq 'passwords') { |
passmin => 'Warning: minimum password length must be a positive integer greater than 6.', |
%intalert = &Apache::lonlocal::texthash ( |
passmax => 'Warning: maximum password length must be a positive integer (or blank).', |
authcheck => 'Warning: disallowing login for an authenticated user if the stored cost is less than the default will require a password reset by/for the user.', |
passexp => 'Warning: days before password expiration must be a positive integer (or blank).', |
authcost => 'Warning: bcrypt encryption cost for internal authentication must be an integer.', |
passnum => 'Warning: number of previous passwords to save must be a positive integer (or blank).', |
passmin => 'Warning: minimum password length must be a positive integer greater than 6.', |
); |
passmax => 'Warning: maximum password length must be a positive integer (or blank).', |
|
passnum => 'Warning: number of previous passwords to save must be a positive integer (or blank).', |
|
); |
|
} elsif ($prefix eq 'secrets') { |
|
%intalert = &Apache::lonlocal::texthash ( |
|
passmin => 'Warning: minimum secret length must be a positive integer greater than 6.', |
|
passmax => 'Warning: maximum secret length must be a positive integer (or blank).', |
|
); |
|
} |
&js_escape(\%intalert); |
&js_escape(\%intalert); |
my $defmin = $Apache::lonnet::passwdmin; |
my $defmin = $Apache::lonnet::passwdmin; |
my $intauthjs = <<"ENDSCRIPT"; |
my $intauthjs; |
|
if ($prefix eq 'passwords') { $intauthjs = <<"ENDSCRIPT"; |
|
|
function warnIntAuth(field) { |
function warnIntAuth(field) { |
if (field.name == 'intauth_check') { |
if (field.name == 'intauth_check') { |
Line 9017 function warnIntAuth(field) {
|
Line 9365 function warnIntAuth(field) {
|
return; |
return; |
} |
} |
|
|
function warnIntPass(field) { |
ENDSCRIPT |
|
|
|
} |
|
|
|
$intauthjs .= <<"ENDSCRIPT"; |
|
|
|
function warnInt$prefix(field) { |
field.value.replace(/^\s+/,''); |
field.value.replace(/^\s+/,''); |
field.value.replace(/\s+\$/,''); |
field.value.replace(/\s+\$/,''); |
var regexdigit=/^\\d+\$/; |
var regexdigit=/^\\d+\$/; |
if (field.name == 'passwords_min') { |
if (field.name == '${prefix}_min') { |
if (field.value == '') { |
if (field.value == '') { |
alert('$intalert{passmin}'); |
alert('$intalert{passmin}'); |
field.value = '$defmin'; |
field.value = '$defmin'; |
Line 9041 function warnIntPass(field) {
|
Line 9395 function warnIntPass(field) {
|
field.value = ''; |
field.value = ''; |
} |
} |
if (field.value != '') { |
if (field.value != '') { |
if (field.name == 'passwords_expire') { |
if (!regexdigit.test(field.value)) { |
var regexpposnum=/^\\d+(|\\.\\d*)\$/; |
if (field.name == '${prefix}_max') { |
if (!regexpposnum.test(field.value)) { |
alert('$intalert{passmax}'); |
alert('$intalert{passexp}'); |
|
field.value = ''; |
|
} else { |
} else { |
var expval = parseFloat(field.value); |
if (field.name == '${prefix}_numsaved') { |
if (expval == 0) { |
alert('$intalert{passnum}'); |
alert('$intalert{passexp}'); |
|
field.value = ''; |
|
} |
|
} |
|
} else { |
|
if (!regexdigit.test(field.value)) { |
|
if (field.name == 'passwords_max') { |
|
alert('$intalert{passmax}'); |
|
} else { |
|
if (field.name == 'passwords_numsaved') { |
|
alert('$intalert{passnum}'); |
|
} |
|
} |
} |
field.value = ''; |
|
} |
} |
|
field.value = ''; |
} |
} |
} |
} |
} |
} |
Line 12641 sub get_ltitools_id {
|
Line 12981 sub get_ltitools_id {
|
return ($id,$error); |
return ($id,$error); |
} |
} |
|
|
|
sub modify_lti { |
|
my ($r,$dom,$action,$lastactref,%domconfig) = @_; |
|
my %domdefaults = &Apache::lonnet::get_domain_defaults($dom,1); |
|
my (%encconfig,$errors,$resulttext); |
|
|
|
my (%currltisec,%secchanges,%newltisec,%newltienc,%keyset,%newkeyset); |
|
$newltisec{'private'}{'keys'} = []; |
|
$newltisec{'encrypt'} = {}; |
|
$newltisec{'rules'} = {}; |
|
$newltisec{'linkprot'} = {}; |
|
if (ref($domconfig{'ltisec'}) eq 'HASH') { |
|
%currltisec = %{$domconfig{'ltisec'}}; |
|
if (ref($currltisec{'linkprot'}) eq 'HASH') { |
|
foreach my $id (keys(%{$currltisec{'linkprot'}})) { |
|
unless ($id =~ /^\d+$/) { |
|
delete($currltisec{'linkprot'}{$id}); |
|
} |
|
} |
|
} |
|
if (ref($currltisec{'private'}) eq 'HASH') { |
|
if (ref($currltisec{'private'}{'keys'}) eq 'ARRAY') { |
|
$newltisec{'private'}{'keys'} = $currltisec{'private'}{'keys'}; |
|
map { $keyset{$_} = 1; } @{$currltisec{'private'}{'keys'}}; |
|
} |
|
} |
|
} |
|
foreach my $item ('crs','dom') { |
|
my $formelement = 'form.ltisec_'.$item.'linkprot'; |
|
if ($env{$formelement}) { |
|
$newltisec{'encrypt'}{$item} = 1; |
|
if (ref($currltisec{'encrypt'}) eq 'HASH') { |
|
unless ($currltisec{'encrypt'}{$item}) { |
|
$secchanges{'encrypt'} = 1; |
|
} |
|
} else { |
|
$secchanges{'encrypt'} = 1; |
|
} |
|
} elsif (ref($currltisec{'encrypt'}) eq 'HASH') { |
|
if ($currltisec{'encrypt'}{$item}) { |
|
$secchanges{'encrypt'} = 1; |
|
} |
|
} |
|
} |
|
unless (exists($currltisec{'rules'})) { |
|
$currltisec{'rules'} = {}; |
|
} |
|
&password_rule_changes('secrets',$newltisec{'rules'},$currltisec{'rules'},\%secchanges); |
|
|
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
my %servers = &Apache::lonnet::get_servers($dom,'library'); |
|
|
|
foreach my $hostid (keys(%servers)) { |
|
if (($hostid ne '') && (grep(/^\Q$hostid\E$/,@ids))) { |
|
my $newkey; |
|
my $keyitem = 'form.ltisec_privkey_'.$hostid; |
|
if (exists($env{$keyitem})) { |
|
$env{$keyitem} =~ s/(`)/'/g; |
|
if ($keyset{$hostid}) { |
|
if ($env{'form.ltisec_changeprivkey_'.$hostid}) { |
|
if ($env{$keyitem} ne '') { |
|
$secchanges{'private'} = 1; |
|
$newkeyset{$hostid} = $env{$keyitem}; |
|
} |
|
} |
|
} elsif ($env{$keyitem} ne '') { |
|
unless (grep(/^\Q$hostid\E$/,@{$newltisec{'private'}{'keys'}})) { |
|
push(@{$newltisec{'private'}{'keys'}},$hostid); |
|
} |
|
$secchanges{'private'} = 1; |
|
$newkeyset{$hostid} = $env{$keyitem}; |
|
} |
|
} |
|
} |
|
} |
|
|
|
my (%linkprotchg,$linkprotoutput,$is_home); |
|
my $proterror = &Apache::courseprefs::process_linkprot($dom,'',$currltisec{'linkprot'}, |
|
\%linkprotchg,'domain'); |
|
my $home = &Apache::lonnet::domain($dom,'primary'); |
|
unless (($home eq 'no_host') || ($home eq '')) { |
|
my @ids=&Apache::lonnet::current_machine_ids(); |
|
foreach my $id (@ids) { if ($id eq $home) { $is_home=1; } } |
|
} |
|
|
|
if (keys(%linkprotchg)) { |
|
$secchanges{'linkprot'} = 1; |
|
my %oldlinkprot; |
|
if (ref($currltisec{'linkprot'}) eq 'HASH') { |
|
%oldlinkprot = %{$currltisec{'linkprot'}}; |
|
} |
|
foreach my $id (keys(%linkprotchg)) { |
|
if (ref($linkprotchg{$id}) eq 'HASH') { |
|
foreach my $inner (keys(%{$linkprotchg{$id}})) { |
|
if (($inner eq 'secret') || ($inner eq 'key')) { |
|
if ($is_home) { |
|
$newltienc{$id}{$inner} = $linkprotchg{$id}{$inner}; |
|
} |
|
} |
|
} |
|
} else { |
|
$newltisec{'linkprot'}{$id} = $linkprotchg{$id}; |
|
} |
|
} |
|
$linkprotoutput = &Apache::courseprefs::store_linkprot($dom,'','domain',\%linkprotchg,\%oldlinkprot); |
|
if (keys(%linkprotchg)) { |
|
%{$newltisec{'linkprot'}} = %linkprotchg; |
|
} |
|
} |
|
if (ref($currltisec{'linkprot'}) eq 'HASH') { |
|
foreach my $id (%{$currltisec{'linkprot'}}) { |
|
next if ($id !~ /^\d+$/); |
|
unless (exists($linkprotchg{$id})) { |
|
if (ref($currltisec{'linkprot'}{$id}) eq 'HASH') { |
|
foreach my $inner (keys(%{$currltisec{'linkprot'}{$id}})) { |
|
if (($inner eq 'secret') || ($inner eq 'key')) { |
|
if ($is_home) { |
|
$newltienc{$id}{$inner} = $currltisec{'linkprot'}{$id}{$inner}; |
|
} |
|
} else { |
|
$newltisec{'linkprot'}{$id}{$inner} = $currltisec{'linkprot'}{$id}{$inner}; |
|
} |
|
} |
|
} else { |
|
$newltisec{'linkprot'}{$id} = $currltisec{'linkprot'}{$id}; |
|
} |
|
} |
|
} |
|
} |
|
if ($proterror) { |
|
$errors .= '<li>'.$proterror.'</li>'; |
|
} |
|
|
|
my $putresult; |
|
if (keys(%secchanges)) { |
|
my %ltienchash; |
|
my %ltihash = ( |
|
'ltisec' => { %newltisec } |
|
); |
|
$putresult = &Apache::lonnet::put_dom('configuration',\%ltihash,$dom); |
|
if ($putresult eq 'ok') { |
|
my %keystore; |
|
if ($secchanges{'private'}) { |
|
my $who = &escape($env{'user.name'}.':'.$env{'user.domain'}); |
|
foreach my $hostid (keys(%newkeyset)) { |
|
my $storehash = { |
|
key => $newkeyset{$hostid}, |
|
who => $env{'user.name'}.':'.$env{'user.domain'}, |
|
}; |
|
$keystore{$hostid} = &Apache::lonnet::store_dom($storehash,'lti','private', |
|
$dom,$hostid); |
|
} |
|
} |
|
if (ref($lastactref) eq 'HASH') { |
|
if (($secchanges{'encrypt'}) || ($secchanges{'private'})) { |
|
$lastactref->{'domdefaults'} = 1; |
|
} |
|
} |
|
if (($secchanges{'linkprot'}) && ($is_home)) { |
|
my %ltienchash = ( |
|
'linkprot' => { %newltienc } |
|
); |
|
&Apache::lonnet::put_dom('encconfig',\%ltienchash,$dom,undef,1); |
|
} |
|
} |
|
} else { |
|
return &mt('No changes made.'); |
|
} |
|
if ($putresult eq 'ok') { |
|
$resulttext = &mt('Changes made:').'<ul>'; |
|
foreach my $item (keys(%secchanges)) { |
|
if ($item eq 'encrypt') { |
|
my %encrypted = ( |
|
crs => { |
|
on => &mt('Encryption of stored link protection secrets defined in courses enabled'), |
|
off => &mt('Encryption of stored link protection secrets defined in courses disabled'), |
|
}, |
|
dom => { |
|
on => &mt('Encryption of stored link protection secrets defined in domain enabled'), |
|
off => &mt('Encryption of stored link protection secrets defined in domain disabled'), |
|
}, |
|
); |
|
foreach my $type ('crs','dom') { |
|
my $shown = $encrypted{$type}{'off'}; |
|
if (ref($newltisec{$item}) eq 'HASH') { |
|
if ($newltisec{$item}{$type}) { |
|
$shown = $encrypted{$type}{'on'}; |
|
} |
|
} |
|
$resulttext .= '<li>'.$shown.'</li>'; |
|
} |
|
} elsif ($item eq 'rules') { |
|
my %titles = &Apache::lonlocal::texthash( |
|
min => 'Minimum password length', |
|
max => 'Maximum password length', |
|
chars => 'Required characters', |
|
); |
|
foreach my $rule ('min','max') { |
|
if ($newltisec{rules}{$rule} eq '') { |
|
if ($rule eq 'min') { |
|
$resulttext .= '<li>'.&mt('[_1] not set.',$titles{$rule}); |
|
' '.&mt('Default of [_1] will be used', |
|
$Apache::lonnet::passwdmin).'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('[_1] set to none',$titles{$rule}).'</li>'; |
|
} |
|
} else { |
|
$resulttext .= '<li>'.&mt('[_1] set to [_2]',$titles{$rule},$newltisec{rules}{$rule}).'</li>'; |
|
} |
|
} |
|
if (ref($newltisec{'rules'}{'chars'}) eq 'ARRAY') { |
|
if (@{$newltisec{'rules'}{'chars'}} > 0) { |
|
my %rulenames = &Apache::lonlocal::texthash( |
|
uc => 'At least one upper case letter', |
|
lc => 'At least one lower case letter', |
|
num => 'At least one number', |
|
spec => 'At least one non-alphanumeric', |
|
); |
|
my $needed = '<ul><li>'. |
|
join('</li><li>',map {$rulenames{$_} } @{$newltisec{'rules'}{'chars'}}). |
|
'</li></ul>'; |
|
$resulttext .= '<li>'.&mt('[_1] set to: [_2]',$titles{'chars'},$needed).'</li>'; |
|
} else { |
|
$resulttext .= '<li>'.&mt('[_1] set to none',$titles{'chars'}).'</li>'; |
|
} |
|
} else { |
|
$resulttext .= '<li>'.&mt('[_1] set to none',$titles{'chars'}).'</li>'; |
|
} |
|
} elsif ($item eq 'private') { |
|
if (keys(%newkeyset)) { |
|
foreach my $hostid (sort(keys(%newkeyset))) { |
|
if ($keystore{$hostid} eq 'ok') { |
|
$resulttext .= '<li>'.&mt('Encryption key for storage of shared secrets saved for [_1]',$hostid).'</li>'; |
|
} |
|
} |
|
} |
|
} elsif ($item eq 'linkprot') { |
|
$resulttext .= $linkprotoutput; |
|
} |
|
} |
|
$resulttext .= '</ul>'; |
|
} else { |
|
$errors .= '<li><span class="LC_error">'.&mt('Failed to save changes').'</span></li>'; |
|
} |
|
if ($errors) { |
|
$resulttext .= &mt('The following errors occurred: ').'<ul>'. |
|
$errors.'</ul>'; |
|
} |
|
return $resulttext; |
|
} |
|
|
sub modify_autoenroll { |
sub modify_autoenroll { |
my ($dom,$lastactref,%domconfig) = @_; |
my ($dom,$lastactref,%domconfig) = @_; |
my ($resulttext,%changes); |
my ($resulttext,%changes); |
Line 14089 sub modify_passwords {
|
Line 14679 sub modify_passwords {
|
$updatedefaults = 1; |
$updatedefaults = 1; |
} |
} |
} |
} |
foreach my $rule ('min','max','numsaved') { |
&password_rule_changes('passwords',\%newvalues,\%current,\%changes); |
$env{'form.passwords_'.$rule} =~ s/^\s+|\s+$//g; |
|
my $ruleok; |
|
if ($rule eq 'min') { |
|
if ($env{'form.passwords_'.$rule} =~ /^\d+$/) { |
|
if ($env{'form.passwords_'.$rule} >= $Apache::lonnet::passwdmin) { |
|
$ruleok = 1; |
|
} |
|
} |
|
} elsif (($env{'form.passwords_'.$rule} =~ /^\d+$/) && |
|
($env{'form.passwords_'.$rule} ne '0')) { |
|
$ruleok = 1; |
|
} |
|
if ($ruleok) { |
|
$newvalues{$rule} = $env{'form.passwords_'.$rule}; |
|
if (exists($current{$rule})) { |
|
if ($newvalues{$rule} ne $current{$rule}) { |
|
$changes{'rules'} = 1; |
|
} |
|
} elsif ($rule eq 'min') { |
|
if ($staticdefaults{$rule} ne $newvalues{$rule}) { |
|
$changes{'rules'} = 1; |
|
} |
|
} else { |
|
$changes{'rules'} = 1; |
|
} |
|
} elsif (exists($current{$rule})) { |
|
$changes{'rules'} = 1; |
|
} |
|
} |
|
my @posschars = &Apache::loncommon::get_env_multiple('form.passwords_chars'); |
|
my @chars; |
|
foreach my $item (sort(@posschars)) { |
|
if ($item =~ /^(uc|lc|num|spec)$/) { |
|
push(@chars,$item); |
|
} |
|
} |
|
$newvalues{'chars'} = \@chars; |
|
unless ($changes{'rules'}) { |
|
if (ref($current{'chars'}) eq 'ARRAY') { |
|
my @diffs = &Apache::loncommon::compare_arrays($current{'chars'},\@chars); |
|
if (@diffs > 0) { |
|
$changes{'rules'} = 1; |
|
} |
|
} else { |
|
if (@chars > 0) { |
|
$changes{'rules'} = 1; |
|
} |
|
} |
|
} |
|
my %crsownerchg = ( |
my %crsownerchg = ( |
by => [], |
by => [], |
for => [], |
for => [], |
Line 14398 sub modify_passwords {
|
Line 14939 sub modify_passwords {
|
return $resulttext; |
return $resulttext; |
} |
} |
|
|
|
sub password_rule_changes { |
|
my ($prefix,$newvalues,$current,$changes) = @_; |
|
return unless ((ref($newvalues) eq 'HASH') && |
|
(ref($current) eq 'HASH') && |
|
(ref($changes) eq 'HASH')); |
|
my (@rules,%staticdefaults); |
|
if ($prefix eq 'passwords') { |
|
@rules = ('min','max','numsaved'); |
|
} elsif ($prefix eq 'secrets') { |
|
@rules = ('min','max'); |
|
} |
|
$staticdefaults{'min'} = $Apache::lonnet::passwdmin; |
|
foreach my $rule (@rules) { |
|
$env{'form.'.$prefix.'_'.$rule} =~ s/^\s+|\s+$//g; |
|
my $ruleok; |
|
if ($rule eq 'min') { |
|
if ($env{'form.'.$prefix.'_'.$rule} =~ /^\d+$/) { |
|
if ($env{'form.'.$prefix.'_'.$rule} >= $staticdefaults{$rule}) { |
|
$ruleok = 1; |
|
} |
|
} |
|
} elsif (($env{'form.'.$prefix.'_'.$rule} =~ /^\d+$/) && |
|
($env{'form.'.$prefix.'_'.$rule} ne '0')) { |
|
$ruleok = 1; |
|
} |
|
if ($ruleok) { |
|
$newvalues->{$rule} = $env{'form.'.$prefix.'_'.$rule}; |
|
if (exists($current->{$rule})) { |
|
if ($newvalues->{$rule} ne $current->{$rule}) { |
|
$changes->{'rules'} = 1; |
|
} |
|
} elsif ($rule eq 'min') { |
|
if ($staticdefaults{$rule} ne $newvalues->{$rule}) { |
|
$changes->{'rules'} = 1; |
|
} |
|
} else { |
|
$changes->{'rules'} = 1; |
|
} |
|
} elsif (exists($current->{$rule})) { |
|
$changes->{'rules'} = 1; |
|
} |
|
} |
|
my @posschars = &Apache::loncommon::get_env_multiple('form.'.$prefix.'_chars'); |
|
my @chars; |
|
foreach my $item (sort(@posschars)) { |
|
if ($item =~ /^(uc|lc|num|spec)$/) { |
|
push(@chars,$item); |
|
} |
|
} |
|
$newvalues->{'chars'} = \@chars; |
|
unless ($changes->{'rules'}) { |
|
if (ref($current->{'chars'}) eq 'ARRAY') { |
|
my @diffs = &Apache::loncommon::compare_arrays($current->{'chars'},\@chars); |
|
if (@diffs > 0) { |
|
$changes->{'rules'} = 1; |
|
} |
|
} else { |
|
if (@chars > 0) { |
|
$changes->{'rules'} = 1; |
|
} |
|
} |
|
} |
|
return; |
|
} |
|
|
sub modify_usercreation { |
sub modify_usercreation { |
my ($dom,%domconfig) = @_; |
my ($dom,%domconfig) = @_; |
my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate,%save_usercreate); |
my ($resulttext,%curr_usercreation,%changes,%authallowed,%cancreate,%save_usercreate); |