Bug 31378: Add domain settings to IdP add page
This patch introduces a small form for an initial domain configuration to the 'New identity provider' page, to avoid confusion on testers about required settings for things to work. To test: 1. Apply this patch 2. Verify you are now offered a configuration section for domain settings. Fields like 'Default category' and 'Default library' are mandatory. 3. Choosing some values makes them get stored on 'Submit' Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com> Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
This commit is contained in:
parent
2dd0cec2e0
commit
f57fb6df4f
|
|
@ -26,6 +26,7 @@ use Try::Tiny qw( catch try );
|
|||
use C4::Auth qw( get_template_and_user );
|
||||
use C4::Output qw( output_html_with_http_headers );
|
||||
|
||||
use Koha::Database;
|
||||
use Koha::Auth::Identity::Providers;
|
||||
|
||||
my $input = CGI->new;
|
||||
|
|
@ -51,33 +52,52 @@ my @messages;
|
|||
|
||||
if ( !$domain_ops && $op eq 'add' ) {
|
||||
|
||||
# IdP configuration params
|
||||
my $code = $input->param('code');
|
||||
my $config = $input->param('config');
|
||||
my $description = $input->param('description');
|
||||
my $icon_url = $input->param('icon_url');
|
||||
my $mapping = $input->param('mapping');
|
||||
my $matchpoint = $input->param('matchpoint'),
|
||||
my $matchpoint = $input->param('matchpoint');
|
||||
my $protocol = $input->param('protocol');
|
||||
# Domain configuration params
|
||||
my $allow_opac = $input->param('allow_opac') // 0;
|
||||
my $allow_staff = $input->param('allow_staff') // 0;
|
||||
my $auto_register = $input->param('auto_register') // 0;
|
||||
my $default_category_id = $input->param('default_category_id');
|
||||
my $default_library_id = $input->param('default_library_id');
|
||||
my $domain = $input->param('domain');
|
||||
my $update_on_auth = $input->param('update_on_$update_on_auth');
|
||||
|
||||
try {
|
||||
my $provider = Koha::Auth::Identity::Provider->new(
|
||||
{ code => $code,
|
||||
config => $config,
|
||||
description => $description,
|
||||
icon_url => $icon_url,
|
||||
mapping => $mapping,
|
||||
matchpoint => $matchpoint,
|
||||
protocol => $protocol,
|
||||
}
|
||||
)->store;
|
||||
Koha::Database->new->schema->txn_do(
|
||||
sub {
|
||||
my $provider = Koha::Auth::Identity::Provider->new(
|
||||
{ code => $code,
|
||||
config => $config,
|
||||
description => $description,
|
||||
icon_url => $icon_url,
|
||||
mapping => $mapping,
|
||||
matchpoint => $matchpoint,
|
||||
protocol => $protocol,
|
||||
}
|
||||
)->store;
|
||||
|
||||
Koha::Auth::Identity::Provider::Domain->new(
|
||||
{
|
||||
identity_provider_id => $provider->identity_provider_id,
|
||||
}
|
||||
)->store;
|
||||
Koha::Auth::Identity::Provider::Domain->new(
|
||||
{ identity_provider_id => $provider->identity_provider_id,
|
||||
allow_opac => $allow_opac,
|
||||
allow_staff => $allow_staff,
|
||||
auto_register => $auto_register,
|
||||
default_category_id => $default_category_id,
|
||||
default_library_id => $default_library_id,
|
||||
domain => $domain,
|
||||
update_on_auth => $update_on_auth,
|
||||
}
|
||||
)->store;
|
||||
|
||||
push @messages, { type => 'message', code => 'success_on_insert' };
|
||||
push @messages, { type => 'message', code => 'success_on_insert' };
|
||||
}
|
||||
);
|
||||
}
|
||||
catch {
|
||||
if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@
|
|||
<option value="1" selected="selected">Allow</option>
|
||||
<option value="0">Don't allow</option>
|
||||
</select>
|
||||
<span>opac users of this domain to login with this identity provider</span>
|
||||
<span>OPAC users from this domain to login with this identity provider.</span>
|
||||
</li>
|
||||
<li>
|
||||
<label for="allow_opac">Allow staff: </label>
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
[% USE raw %]
|
||||
[% USE Asset %]
|
||||
[% USE Branches %]
|
||||
[% USE Categories %]
|
||||
[% SET footerjs = 1 %]
|
||||
[% INCLUDE 'doc-head-open.inc' %]
|
||||
<title>
|
||||
|
|
@ -87,6 +89,7 @@
|
|||
<form action="/cgi-bin/koha/admin/identity_providers.pl" id="add" name="add" class="validated" method="post">
|
||||
<input type="hidden" name="op" value="add" />
|
||||
<fieldset class="rows">
|
||||
<legend id="identity_provider_basic">Basic configuration</legend>
|
||||
<ol>
|
||||
<li>
|
||||
<label for="code" class="required">Code: </label>
|
||||
|
|
@ -116,10 +119,11 @@
|
|||
</fieldset>
|
||||
|
||||
<fieldset class="rows">
|
||||
<legend id="identity_provider_advanced">Advanced configuration</legend>
|
||||
<ol>
|
||||
<li>
|
||||
<label for="config" class="required json">Configuration: </label>
|
||||
<textarea name="config" id="config" class="required"></textarea>
|
||||
<textarea name="config" id="config" class="required" cols="75" rows="10"></textarea>
|
||||
<span class="required">Required</span>
|
||||
<div class="hint">Provider's main configuration. <button class="more btn btn-ligth" data-target="config"><i class="fa fa-caret-down"></i> More</button></div>
|
||||
<div class="hint more-config" style="display: none">
|
||||
|
|
@ -132,7 +136,7 @@
|
|||
</li>
|
||||
<li>
|
||||
<label for="mapping" class="required json">Mapping: </label>
|
||||
<textarea name="mapping" id="mapping" class="required"></textarea>
|
||||
<textarea name="mapping" id="mapping" class="required" cols="75" rows="10"></textarea>
|
||||
<span class="required">Required</span>
|
||||
<div class="hint">Map provider's result to Koha patron's fields. <button class="more btn btn-ligth" data-target="mapping"><i class="fa fa-caret-down"></i> More</button></div>
|
||||
<div class="hint more-mapping" style="display: none">
|
||||
|
|
@ -162,6 +166,69 @@
|
|||
</li>
|
||||
</ol>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="rows">
|
||||
<legend id="identity_provider_domain">Domain configuration</legend>
|
||||
<ol>
|
||||
<li>
|
||||
<label for="domain" class="required">Domain: </label>
|
||||
<input type="text" name="domain" id="domain" class="required" size="60" />
|
||||
<span class="required">Required</span>
|
||||
<div class="hint">Use * for any domain. You can add new domains later on the dedicated admin page.</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="default_library_id">Default library: </label>
|
||||
<select id="default_library_id" name="default_library_id" class="mandatory">
|
||||
[% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1, do_not_select_my_library => 1 ) %]
|
||||
</select>
|
||||
<span class="required">Required</span>
|
||||
<div class="hint">Use this library for the patron on auto register</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="default_category_id">Default category: </label>
|
||||
[% SET categories = Categories.all() %]
|
||||
<select name="default_category_id" id="default_category_id" class="mandatory">
|
||||
[% FOREACH category IN categories %]
|
||||
<option value="[% category.categorycode | html %]">[% category.description | html %]</option>
|
||||
[% END %]
|
||||
</select>
|
||||
<span class="required">Required</span>
|
||||
<div class="hint">Use this category for the patron on auto register</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="allow_opac">Allow OPAC: </label>
|
||||
<select name="allow_opac" id="allow_opac">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0" selected="selected">No</option>
|
||||
</select>
|
||||
<div class="hint">Allow OPAC access to users from this domain to login with this identity provider.</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="allow_opac">Allow staff: </label>
|
||||
<select name="allow_staff" id="allow_staff">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0" selected="selected">No</option>
|
||||
</select>
|
||||
<div class="hint">Allow staff access to users from this domain to login with this identity provider.</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="auto_register">Auto register: </label>
|
||||
<select name="auto_register" id="auto_register">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0" selected="selected">No</option>
|
||||
</select>
|
||||
<div class="hint">Allow users to auto register on login.</div>
|
||||
</li>
|
||||
<li>
|
||||
<label for="update_on_auth">Update on login: </label>
|
||||
<select name="update_on_auth" id="update_on_auth">
|
||||
<option value="1">Yes</option>
|
||||
<option value="0" selected="selected">No</option>
|
||||
</select>
|
||||
<div class="hint">Update user data on login.</div>
|
||||
</ol>
|
||||
</fieldset>
|
||||
|
||||
<fieldset class="action">
|
||||
<input type="submit" value="Submit" />
|
||||
<a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl">Cancel</a>
|
||||
|
|
|
|||
Loading…
Reference in New Issue