Bugzilla – Attachment 143231 Details for
Bug 31378
Add a generic OAuth2/OIDC client implementation
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31378: Add an administration interface for authentication sources
Bug-31378-Add-an-administration-interface-for-auth.patch (text/plain), 58.09 KB, created by
Tomás Cohen Arazi (tcohen)
on 2022-11-04 15:01:11 UTC
(
hide
)
Description:
Bug 31378: Add an administration interface for authentication sources
Filename:
MIME Type:
Creator:
Tomás Cohen Arazi (tcohen)
Created:
2022-11-04 15:01:11 UTC
Size:
58.09 KB
patch
obsolete
>From 09b74a1cf6ccf798d4f9e3d39d13d7c62eaf7904 Mon Sep 17 00:00:00 2001 >From: Agustin Moyano <agustinmoyano@theke.io> >Date: Fri, 23 Sep 2022 15:02:48 -0300 >Subject: [PATCH] Bug 31378: Add an administration interface for authentication > sources > >Signed-off-by: Lukasz Koszyk <lukasz.koszyk@kit.edu> >Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io> >--- > admin/authentication_providers.pl | 299 +++++++++++ > .../prog/en/includes/admin-menu.inc | 5 +- > .../prog/en/modules/admin/admin-home.tt | 6 +- > .../admin/authentication_provider_domains.tt | 476 ++++++++++++++++++ > .../modules/admin/authentication_providers.tt | 466 +++++++++++++++++ > 5 files changed, 1250 insertions(+), 2 deletions(-) > create mode 100644 admin/authentication_providers.pl > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/authentication_provider_domains.tt > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/modules/admin/authentication_providers.tt > >diff --git a/admin/authentication_providers.pl b/admin/authentication_providers.pl >new file mode 100644 >index 00000000000..07c33b93242 >--- /dev/null >+++ b/admin/authentication_providers.pl >@@ -0,0 +1,299 @@ >+#!/usr/bin/perl >+ >+# Copyright 2022 Theke Solutions >+# >+# This file is part of Koha. >+# >+# Koha 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; either version 3 of the License, or >+# (at your option) any later version. >+# >+# Koha 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. >+# >+# You should have received a copy of the GNU General Public License >+# along with Koha; if not, see <http://www.gnu.org/licenses>. >+ >+use Modern::Perl; >+ >+use CGI qw ( -utf8 ); >+use Scalar::Util qw( blessed ); >+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::Auth::Providers; >+ >+my $input = CGI->new; >+my $op = $input->param('op') || 'list'; >+my $domain_ops = $input->param('domain_ops'); >+my $auth_provider_id = $input->param('auth_provider_id'); >+my $auth_provider; >+ >+$auth_provider = Koha::Auth::Providers->find($auth_provider_id) >+ unless !$auth_provider_id; >+ >+my $template_name = $domain_ops ? 'admin/authentication_provider_domains.tt' : 'admin/authentication_providers.tt'; >+ >+my ( $template, $borrowernumber, $cookie ) = get_template_and_user( >+ { template_name => $template_name, >+ query => $input, >+ type => "intranet", >+ flagsrequired => { parameters => 'manage_authentication_providers' }, >+ } >+); >+ >+my @messages; >+ >+if ( !$domain_ops && $op eq 'add' ) { >+ >+ 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 $protocol = $input->param('protocol'); >+ >+ try { >+ my $provider = Koha::Auth::Provider->new( >+ { code => $code, >+ config => $config, >+ description => $description, >+ icon_url => $icon_url, >+ mapping => $mapping, >+ matchpoint => $matchpoint, >+ protocol => $protocol, >+ } >+ )->store; >+ >+ Koha::Auth::Provider::Domain->new( >+ { >+ auth_provider_id => $provider->auth_provider_id, >+ } >+ )->store; >+ >+ push @messages, { type => 'message', code => 'success_on_insert' }; >+ } >+ catch { >+ if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_insert', >+ reason => 'duplicate_id' >+ }; >+ } >+ }; >+ >+ # list servers after adding >+ $op = 'list'; >+} >+elsif ( $domain_ops && $op eq 'add' ) { >+ >+ my $allow_opac = $input->param('allow_opac'); >+ my $allow_staff = $input->param('allow_staff'); >+ my $auth_provider_id = $input->param('auth_provider_id'); >+ my $auto_register = $input->param('auto_register'); >+ 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_auth'); >+ >+ try { >+ >+ Koha::Auth::Provider::Domain->new( >+ { >+ allow_opac => $allow_opac, >+ allow_staff => $allow_staff, >+ auth_provider_id => $auth_provider_id, >+ 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' }; >+ } >+ catch { >+ if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_insert', >+ reason => 'duplicate_id' >+ }; >+ } >+ }; >+ >+ # list servers after adding >+ $op = 'list'; >+} >+elsif ( !$domain_ops && $op eq 'edit_form' ) { >+ >+ if ( $auth_provider ) { >+ $template->param( >+ auth_provider => $auth_provider >+ ); >+ } >+ else { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_edit', >+ reason => 'invalid_id' >+ }; >+ } >+} >+elsif ( $domain_ops && $op eq 'edit_form' ) { >+ my $auth_provider_domain_id = $input->param('auth_provider_domain_id'); >+ my $auth_provider_domain; >+ >+ $auth_provider_domain = Koha::Auth::Provider::Domains->find($auth_provider_domain_id) >+ unless !$auth_provider_domain_id; >+ >+ if ( $auth_provider_domain ) { >+ $template->param( >+ auth_provider_domain => $auth_provider_domain >+ ); >+ } >+ else { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_edit', >+ reason => 'invalid_id' >+ }; >+ } >+} >+elsif ( !$domain_ops && $op eq 'edit_save' ) { >+ >+ if ( $auth_provider ) { >+ >+ 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 $protocol = $input->param('protocol'); >+ >+ try { >+ >+ $auth_provider->set( >+ { code => $code, >+ config => $config, >+ description => $description, >+ icon_url => $icon_url, >+ mapping => $mapping, >+ matchpoint => $matchpoint, >+ protocol => $protocol, >+ } >+ )->store; >+ >+ push @messages, >+ { >+ type => 'message', >+ code => 'success_on_update' >+ }; >+ } >+ catch { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_update' >+ }; >+ }; >+ >+ # list servers after adding >+ $op = 'list'; >+ } >+ else { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_update', >+ reason => 'invalid_id' >+ }; >+ } >+} >+elsif ( $domain_ops && $op eq 'edit_save' ) { >+ >+ my $auth_provider_domain_id = $input->param('auth_provider_domain_id'); >+ my $auth_provider_domain; >+ >+ $auth_provider_domain = Koha::Auth::Provider::Domains->find($auth_provider_domain_id) >+ unless !$auth_provider_domain_id; >+ >+ if ( $auth_provider_domain ) { >+ >+ my $auth_provider_id = $input->param('auth_provider_id'); >+ my $domain = $input->param('domain'); >+ my $auto_register = $input->param('auto_register'); >+ my $update_on_auth = $input->param('update_on_auth'); >+ my $default_library_id = $input->param('default_library_id'); >+ my $default_category_id = $input->param('default_category_id'); >+ my $allow_opac = $input->param('allow_opac'); >+ my $allow_staff = $input->param('allow_staff'); >+ >+ try { >+ >+ $auth_provider_domain->set( >+ { >+ auth_provider_id => $auth_provider_id, >+ domain => $domain, >+ auto_register => $auto_register, >+ update_on_auth => $update_on_auth, >+ default_library_id => $default_library_id, >+ default_category_id => $default_category_id, >+ allow_opac => $allow_opac, >+ allow_staff => $allow_staff, >+ } >+ )->store; >+ >+ push @messages, >+ { >+ type => 'message', >+ code => 'success_on_update' >+ }; >+ } >+ catch { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_update' >+ }; >+ }; >+ >+ # list servers after adding >+ $op = 'list'; >+ } >+ else { >+ push @messages, >+ { >+ type => 'alert', >+ code => 'error_on_update', >+ reason => 'invalid_id' >+ }; >+ } >+} >+ >+if ( $domain_ops ) { >+ $template->param( >+ auth_provider_code => $auth_provider->code, >+ auth_provider_id => $auth_provider_id, >+ ); >+} >+ >+$template->param( >+ op => $op, >+ messages => \@messages, >+); >+ >+output_html_with_http_headers $input, $cookie, $template->output; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >index 356ae1ab8ba..fa771e629f5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc >@@ -141,9 +141,12 @@ > </ul> > [% END %] > >- [% IF ( CAN_user_parameters_manage_smtp_servers || CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || ( CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_additional_fields || ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) ) %] >+ [% IF ( CAN_user_parameters_manage_authentication_providers || CAN_user_parameters_manage_smtp_servers || CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || ( CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_additional_fields || ( Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts ) ) %] > <h5>Additional parameters</h5> > <ul> >+ [% IF ( CAN_user_parameters_manage_authentication_providers) %] >+ <li><a href="/cgi-bin/koha/admin/authentication_providers.pl">Authentication providers</a></li> >+ [% END %] > [% IF ( CAN_user_parameters_manage_search_targets ) %] > <li><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></li> > [% END %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >index 79a6853e537..4cc7f831399 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt >@@ -238,11 +238,15 @@ > </dl> > [% END %] > >- [% IF ( ( CAN_user_parameters_manage_smtp_servers || CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_additional_fields || CAN_user_parameters_manage_mana || (Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts) ) %] >+ [% IF ( ( CAN_user_parameters_manage_authentication_providers || CAN_user_parameters_manage_smtp_servers || CAN_user_parameters_manage_search_targets || CAN_user_parameters_manage_didyoumean || CAN_user_parameters_manage_column_config || CAN_user_parameters_manage_audio_alerts || CAN_user_parameters_manage_sms_providers && Koha.Preference('SMSSendDriver') == 'Email' ) || CAN_user_parameters_manage_usage_stats || CAN_user_parameters_manage_additional_fields || CAN_user_parameters_manage_mana || (Koha.Preference('EnableAdvancedCatalogingEditor') && CAN_user_parameters_manage_keyboard_shortcuts) ) %] > <h3>Additional parameters</h3> > <dl> > <!-- <dt><a href="/cgi-bin/koha/admin/printers.pl">Network Printers</a></dt> > <dd>Printers (UNIX paths).</dd> --> >+ [% IF ( CAN_user_parameters_manage_authentication_providers) %] >+ <dt><a href="/cgi-bin/koha/admin/authentication_providers.pl">Authentication providers</a></dt> >+ <dd>Define which external authentication providers to use</dd> >+ [% END %] > [% IF ( CAN_user_parameters_manage_search_targets ) %] > <dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></dt> > <dd>Define which external servers to query for MARC data</dd> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authentication_provider_domains.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authentication_provider_domains.tt >new file mode 100644 >index 00000000000..582842ae08d >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authentication_provider_domains.tt >@@ -0,0 +1,476 @@ >+[% USE raw %] >+[% USE Asset %] >+[% USE Branches %] >+[% USE Categories %] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title> >+ [% IF op == 'add_form' %] >+ New authentication provider domain › [% ELSIF op == 'edit_form' %] >+ Edit authentication provider domain › [% END %] >+ >+ Authentication providers › Administration › Koha >+</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+ >+<body id="admin_auth_provider_domains" class="admin"> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'prefs-admin-search.inc' %] >+ >+<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb"> >+ <ol> >+ <li> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> >+ </li> >+ <li> >+ <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> >+ </li> >+ >+ <li> >+ <a href="/cgi-bin/koha/admin/authentication_providers.pl">Authentication providers</a> >+ </li> >+ >+ [% IF op == 'add_form' %] >+ <li> >+ <a href="/cgi-bin/koha/admin/authentication_providers.pl?domain_ops=1&auth_provider_id=[%- auth_provider_id | uri -%]">Domains for [%- auth_provider_name | html -%]</a> >+ </li> >+ <li> >+ <a href="#" aria-current="page"> >+ New Domain >+ </a> >+ </li> >+ >+ [% ELSIF op == 'edit_form' %] >+ <li> >+ <a href="/cgi-bin/koha/admin/authentication_providers.pl?domain_ops=1&auth_provider_id=[%- auth_provider_id | uri -%]">Domains for [%- auth_provider_name | html -%]</a> >+ </li> >+ <li> >+ <a href="#" aria-current="page"> >+ Edit Domain >+ </a> >+ </li> >+ >+ [% ELSE %] >+ <li> >+ <a href="#" aria-current="page"> >+ Domains for [%- auth_provider_code | html -%] >+ </a> >+ </li> >+ [% END %] >+ </ol> >+</nav> >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+ <main> >+ >+[% FOREACH m IN messages %] >+ <div class="dialog [% m.type | html %]" id="auth_provider_domain_action_result_dialog"> >+ [% SWITCH m.code %] >+ [% CASE 'error_on_update' %] >+ <span>An error occurred trying to open the authentication provider domain for editing. The passed id is invalid.</span> >+ [% CASE 'error_on_insert' %] >+ <span>An error occurred when adding a new authentication provider domain.</span> >+ [% CASE 'success_on_update' %] >+ <span>Authentication provider domain updated successfully.</span> >+ [% CASE 'success_on_insert' %] >+ <span>Authentication provider domain added successfully.</span> >+ [% CASE %] >+ <span>[% m.code | html %]</span> >+ [% END %] >+ </div> >+[% END %] >+ >+ <div class="dialog message" id="auth_provider_domain_delete_success" style="display: none;"></div> >+ <div class="dialog alert" id="auth_provider_domain_delete_error" style="display: none;"></div> >+ >+[% IF op == 'add_form' %] >+ <h1>New authentication provider domain</h1> >+ <form action="/cgi-bin/koha/admin/authentication_providers.pl" id="add" name="add" class="validated" method="post"> >+ <input type="hidden" name="op" value="add" /> >+ <input type="hidden" name="domain_ops" value="1" /> >+ <input type="hidden" name="auth_provider_id" value="[%- auth_provider_id | html -%]" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="domain">Domain: </label> >+ <input type="text" name="domain" id="domain" size="60" /> >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="update_on_auth">Update on login: </label> >+ <select name="update_on_auth" id="update_on_auth"> >+ <option value="1">Update</option> >+ <option value="0" selected="selected">Don't update</option> >+ </select> >+ <span>user data on login</span> >+ </li> >+ <li> >+ <label for="auto_register">Auto register: </label> >+ <select name="auto_register" id="auto_register"> >+ <option value="1">Allow</option> >+ <option value="0" selected="selected">Don't allow</option> >+ </select> >+ <span>users to auto register on login</span> >+ </li> >+ <li> >+ <label for="default_library_id">Default library: </label> >+ <select id="default_library_id" name="default_library_id"> >+ [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1, do_not_select_my_library => 1 ) %] >+ </select> >+ </li> >+ <li> >+ <label for="default_category_id">Default category: </label> >+ [% SET categories = Categories.all() %] >+ <select name="default_category_id" id="default_category_id"> >+ [% FOREACH category IN categories %] >+ <option value="[% category.categorycode | html %]">[% category.description | html %]</option> >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="allow_opac">Allow opac: </label> >+ <select name="allow_opac" id="allow_opac"> >+ <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 authentication provider</span> >+ </li> >+ <li> >+ <label for="allow_opac">Allow staff: </label> >+ <select name="allow_staff" id="allow_staff"> >+ <option value="1" selected="selected">Allow</option> >+ <option value="0">Don't allow</option> >+ </select> >+ <span>of this domain </span> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Submit" /> >+ <a class="cancel" href="/cgi-bin/koha/admin/authentication_providers.pl?domain_ops=1&auth_provider_id=[%- auth_provider_id | html -%]">Cancel</a> >+ </fieldset> >+ </form> >+[% END %] >+ >+[% IF op == 'edit_form' %] >+ <h1>Edit authentication provider domain</h1> >+ <form action="/cgi-bin/koha/admin/authentication_providers.pl" id="edit_save" name="edit_save" class="validated" method="post"> >+ <input type="hidden" name="op" value="edit_save" /> >+ <input type="hidden" name="domain_ops" value="1" /> >+ <input type="hidden" name="auth_provider_id" value="[%- auth_provider_id | html -%]" /> >+ <input type="hidden" name="auth_provider_domain_id" value="[%- auth_provider_domain.auth_provider_domain_id | html -%]" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="domain">Domain: </label> >+ <input type="text" name="domain" id="domain" size="60" value="[%- auth_provider_domain.domain | html -%]"/> >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="update_on_auth">Update on login: </label> >+ <select name="update_on_auth" id="update_on_auth"> >+ [% IF auth_provider_domain.update_on_auth == "1" %] >+ <option value="1" selected="selected">Update</option> >+ <option value="0">Don't update</option> >+ [% ELSE %] >+ <option value="1">Update</option> >+ <option value="0" selected="selected">Don't update</option> >+ [% END %] >+ </select> >+ <span>user data on login</span> >+ </li> >+ <li> >+ <label for="auto_register">Auto register: </label> >+ <select name="auto_register" id="auto_register"> >+ [% IF auth_provider_domain.auto_register == "1" %] >+ <option value="1" selected="selected">Allow</option> >+ <option value="0">Don't allow</option> >+ [% ELSE %] >+ <option value="1">Allow</option> >+ <option value="0" selected="selected">Don't allow</option> >+ [% END %] >+ </select> >+ <span>users to auto register on login</span> >+ </li> >+ <li> >+ <label for="default_library_id">Default library: </label> >+ <select id="default_library_id" name="default_library_id"> >+ [% PROCESS options_for_libraries libraries => Branches.all( selected => auth_provider_domain.default_library_id, unfiltered => 1, do_not_select_my_library => 1 ) %] >+ </select> >+ </li> >+ <li> >+ <label for="default_category_id">Default category: </label> >+ [% SET categories = Categories.all() %] >+ <select name="default_category_id" id="default_category_id"> >+ [% FOREACH category IN categories %] >+ [% IF category.categorycode == auth_provider_domain.default_category_id %] >+ <option value="[% category.categorycode | html %]" selected="selected">[% category.description | html %]</option> >+ [% ELSE %] >+ <option value="[% category.categorycode | html %]">[% category.description | html %]</option> >+ [% END %] >+ [% END %] >+ </select> >+ </li> >+ <li> >+ <label for="allow_opac">Allow opac: </label> >+ <select name="allow_opac" id="allow_opac"> >+ [% IF auth_provider_domain.allow_opac == "1" %] >+ <option value="1" selected="selected">Allow</option> >+ <option value="0">Don't allow</option> >+ [% ELSE %] >+ <option value="1">Allow</option> >+ <option value="0" selected="selected">Don't allow</option> >+ [% END %] >+ </select> >+ <span>opac users of this domain to login with this authentication provider</span> >+ </li> >+ <li> >+ <label for="allow_opac">Allow staff: </label> >+ <select name="allow_staff" id="allow_staff"> >+ [% IF auth_provider_domain.allow_staff == "1" %] >+ <option value="1" selected="selected">Allow</option> >+ <option value="0">Don't allow</option> >+ [% ELSE %] >+ <option value="1">Allow</option> >+ <option value="0" selected="selected">Don't allow</option> >+ [% END %] >+ </select> >+ <span>staff users of this domain to login with this authentication provider</span> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Submit" /> >+ <a class="cancel" href="/cgi-bin/koha/admin/authentication_providers.pl?domain_ops=1&auth_provider_id=[%- auth_provider_id | html -%]">Cancel</a> >+ </fieldset> >+ </form> >+[% END %] >+ >+[% IF op == 'list' %] >+ >+ <div id="toolbar" class="btn-toolbar"> >+ <a class="btn btn-default" id="new_auth_provider_domain" href="/cgi-bin/koha/admin/authentication_providers.pl?domain_ops=1&auth_provider_id=[%- auth_provider_id | html -%]&op=add_form"><i class="fa fa-plus"></i> New authentication provider domain</a> >+ </div> >+ >+ <h1>Authentication provider domains</h1> >+ >+ <table id="auth_provider_domains"> >+ <thead> >+ <tr> >+ <th>Domain</th> >+ <th>Update on login</th> >+ <th>Auto register</th> >+ <th>Default library</th> >+ <th>Default category</th> >+ <th>Allow opac</th> >+ <th>Allow staff</th> >+ <th data-class-name="actions noExport">Actions</th> >+ </tr> >+ </thead> >+ </table> >+[% END %] >+ >+ <div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="delete_confirm_modal_label">Delete authentication provider domain</h3> >+ </div> >+ <div class="modal-body"> >+ <div id="delete_confirm_dialog"></div> >+ </div> >+ <div class="modal-footer"> >+ <a href="#" class="btn btn-default" id="delete_confirm_modal_button" role="button" data-toggle="modal">Delete</a> >+ <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> >+ </div> >+ </div> <!-- /.modal-content --> >+ </div> <!-- /.modal-dialog --> >+ </div> <!-- #delete_confirm_modal --> >+ >+ </main> >+ </div> <!-- /.col-sm-10.col-sm-push-2 --> >+ >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'admin-menu.inc' %] >+ </aside> >+ </div> <!-- /.col-sm-2.col-sm-pull-10 --> >+ </div> <!-- /.row --> >+ >+ >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/admin-menu.js") | $raw %] >+ [% INCLUDE 'datatables.inc' %] >+ <script> >+ $(document).ready(function() { >+ >+ var auth_provider_domains_url = '/api/v1/auth/providers/[%- auth_provider_id | html -%]/domains'; >+ [% SET categories = Categories.all() %] >+ var categories = { >+ [% FOREACH category IN categories %] >+ "[% category.categorycode | html %]": "[% category.description | html %]", >+ [% END %] >+ }; >+ [% SET libraries = Branches.all() %] >+ var libraries = { >+ [% FOREACH library IN libraries %] >+ "[% library.branchcode | html %]": "[% library.branchname | html %]", >+ [% END %] >+ }; >+ window.auth_provider_domains = $("#auth_provider_domains").kohaTable({ >+ "ajax": { >+ "url": auth_provider_domains_url >+ }, >+ 'language': { >+ 'emptyTable': '<div class="dialog message">'+_("There are no authentication provider domains defined.")+'</div>' >+ }, >+ "columnDefs": [ { >+ "targets": [1], >+ "render": function (data, type, row, meta) { >+ if ( type == 'display' ) { >+ if ( data != null ) { >+ return data.escapeHtml(); >+ } >+ else { >+ return ""; >+ } >+ } >+ return data; >+ } >+ } ], >+ "columns": [ >+ { >+ "data": "domain", >+ "searchable": true, >+ "orderable": true, >+ "render": function(data, type, row, meta) { >+ if ( data != null ) { >+ return data.escapeHtml(); >+ } >+ else { >+ return "*"; >+ } >+ } >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ if (row.update_on_auth) { >+ return _("Yes"); >+ } else { >+ return _("No"); >+ } >+ }, >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ if (row.auto_register) { >+ return _("Yes"); >+ } else { >+ return _("No"); >+ } >+ }, >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ return libraries[row.default_library_id] || ""; >+ }, >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ return categories[row.default_category_id] || ""; >+ }, >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ if (row.allow_opac) { >+ return _("Yes"); >+ } else { >+ return _("No"); >+ } >+ }, >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ if (row.allow_staff) { >+ return _("Yes"); >+ } else { >+ return _("No"); >+ } >+ }, >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/authentication_providers.pl?domain_ops=1&auth_provider_id=[%- auth_provider_id | html -%]&op=edit_form&auth_provider_domain_id='+ encodeURIComponent(row.auth_provider_domain_id) +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n"; >+ result += '<a class="btn btn-default btn-xs delete_auth_provider_domain" role="button" href="#" data-toggle="modal" data-target="#delete_confirm_modal" data-auth-provider-domain-id="'+ encodeURIComponent(row.auth_provider_domain_id) +'" data-auth-provider-domain="'+ encodeURIComponent((row.domain || '').escapeHtml()) +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>'; >+ return result; >+ }, >+ "searchable": false, >+ "orderable": false >+ } >+ ], >+ createdRow: function (row, data, dataIndex) { >+ if ( data.debug ) { >+ $(row).addClass('debug'); >+ } >+ }, >+ }); >+ >+ $('#auth_provider_domains').on( "click", '.delete_auth_provider_domain', function () { >+ var auth_provider_domain_id = $(this).data('auth-provider-domain-id'); >+ var auth_provider_domain = decodeURIComponent($(this).data('auth-provider-domain')); >+ >+ $("#delete_confirm_dialog").html( >+ _("You are about to delete the '%s' authentication provider domain.").format(auth_provider_domain) >+ ); >+ $("#delete_confirm_modal_button").data('auth-provider-domain-id', auth_provider_domain_id); >+ $("#delete_confirm_modal_button").data('auth-provider-domain', auth_provider_domain); >+ }); >+ >+ $("#delete_confirm_modal_button").on( "click", function () { >+ >+ var auth_provider_domain_id = $(this).data('auth-provider-domain-id'); >+ var auth_provider_domain = $(this).data('auth-provider-domain'); >+ >+ $.ajax({ >+ method: "DELETE", >+ url: auth_provider_domains_url+"/"+auth_provider_domain_id >+ }).success(function() { >+ window.auth_provider_domains.api().ajax.reload(function (data) { >+ $("#smtp_action_result_dialog").hide(); >+ $("#smtp_delete_success").html(_("Server '%s' deleted successfully.").format(auth_provider_domain)).show(); >+ }); >+ }).fail(function () { >+ $("#smtp_delete_error").html(_("Error deleting server '%s'. Check the logs.").format(auth_provider_domain)).show(); >+ }).done(function () { >+ $("#delete_confirm_modal").modal('hide'); >+ }); >+ }); >+ }); >+ </script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authentication_providers.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authentication_providers.tt >new file mode 100644 >index 00000000000..a33428840f0 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/admin/authentication_providers.tt >@@ -0,0 +1,466 @@ >+[% USE raw %] >+[% USE Asset %] >+[% SET footerjs = 1 %] >+[% INCLUDE 'doc-head-open.inc' %] >+<title> >+ [% IF op == 'add_form' %] >+ New authentication provider › [% ELSIF op == 'edit_form' %] >+ Edit authentication provider › [% END %] >+ >+ Authentication providers › Administration › Koha >+</title> >+[% INCLUDE 'doc-head-close.inc' %] >+</head> >+ >+<body id="admin_auth_providers" class="admin"> >+[% INCLUDE 'header.inc' %] >+[% INCLUDE 'prefs-admin-search.inc' %] >+ >+<nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb"> >+ <ol> >+ <li> >+ <a href="/cgi-bin/koha/mainpage.pl">Home</a> >+ </li> >+ <li> >+ <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> >+ </li> >+ >+ [% IF op == 'add_form' %] >+ <li> >+ <a href="/cgi-bin/koha/admin/authentication_providers.pl">Authentication providers</a> >+ </li> >+ <li> >+ <a href="#" aria-current="page"> >+ New >+ </a> >+ </li> >+ >+ [% ELSIF op == 'edit_form' %] >+ <li> >+ <a href="/cgi-bin/koha/admin/authentication_providers.pl">Authentication providers</a> >+ </li> >+ <li> >+ <a href="#" aria-current="page"> >+ Edit >+ </a> >+ </li> >+ >+ [% ELSE %] >+ <li> >+ <a href="#" aria-current="page"> >+ Authentication providers >+ </a> >+ </li> >+ [% END %] >+ </ol> >+</nav> >+ >+<div class="main container-fluid"> >+ <div class="row"> >+ <div class="col-sm-10 col-sm-push-2"> >+ <main> >+ >+[% FOREACH m IN messages %] >+ <div class="dialog [% m.type | html %]" id="auth_provider_action_result_dialog"> >+ [% SWITCH m.code %] >+ [% CASE 'error_on_update' %] >+ <span>An error occurred trying to open the authentication provider for editing. The passed id is invalid.</span> >+ [% CASE 'error_on_insert' %] >+ <span>An error occurred when adding a new authentication provider.</span> >+ [% CASE 'success_on_update' %] >+ <span>Authentication provider updated successfully.</span> >+ [% CASE 'success_on_insert' %] >+ <span>Authentication provider added successfully.</span> >+ [% CASE %] >+ <span>[% m.code | html %]</span> >+ [% END %] >+ </div> >+[% END %] >+ >+ <div class="dialog message" id="auth_provider_delete_success" style="display: none;"></div> >+ <div class="dialog alert" id="auth_provider_delete_error" style="display: none;"></div> >+ >+[% IF op == 'add_form' %] >+ <h1>New authentication provider</h1> >+ <form action="/cgi-bin/koha/admin/authentication_providers.pl" id="add" name="add" class="validated" method="post"> >+ <input type="hidden" name="op" value="add" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="code" class="required">Code: </label> >+ <input type="text" name="code" id="code" size="60" class="required" required="required" /> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="description" class="required">Description: </label> >+ <input type="text" name="description" id="description" size="60" class="required" required="required" /> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="protocol">Protocol: </label> >+ <select name="protocol" id="protocol"> >+ <option value="OAuth">OAuth</option> >+ <option value="OIDC">OIDC</option> >+ <!-- Not implemented yet >+ <option value="LDAP">LDAP</option> >+ <option value="CAS">CAS</option> >+ --> >+ </select> >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <div> >+ <label for="config" class="required json">Configuration: </label> >+ <textarea name="config" id="config" class="required"></textarea> >+ <span class="required">Required</span> >+ </div> >+ <div> >+ <label></label> >+ <button class="btn btn-ligth defaults" data-default-target="config" id="default-config">Add default OAuth configuration</button> >+ </div> >+ </li> >+ <li> >+ <div> >+ <label for="mapping" class="required json">Mapping: </label> >+ <textarea name="mapping" id="mapping" class="required"></textarea> >+ <span class="required">Required</span> >+ </div> >+ <div> >+ <label></label> >+ <button class="btn btn-ligth defaults" data-default-target="mapping" id="default-mapping">Add default OAuth mapping</button> >+ </div> >+ </li> >+ <li> >+ <label for="matchpoint" class="required">Matchpoint: </label> >+ <select name="matchpoint" id="matchpoint" class="required"> >+ <option value="email">Email</option> >+ <option value="userid">User id</option> >+ <option value="cardnumber">Card number</option> >+ </select> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="icon_url">Icon URL: </label> >+ <input type="text" name="icon_url" id="icon_url" size="60" /> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Submit" /> >+ <a class="cancel" href="/cgi-bin/koha/admin/authentication_providers.pl">Cancel</a> >+ </fieldset> >+ </form> >+[% END %] >+ >+[% IF op == 'edit_form' %] >+ <h1>Edit authentication provider</h1> >+ <form action="/cgi-bin/koha/admin/authentication_providers.pl" id="edit_save" name="edit_save" class="validated" method="post"> >+ <input type="hidden" name="op" value="edit_save" /> >+ <input type="hidden" name="auth_provider_id" value="[%- auth_provider.auth_provider_id | html -%]" /> >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <label for="code" class="required">Code: </label> >+ <input type="text" name="code" id="code" size="60" class="required" required="required" value="[%- auth_provider.code | html -%]"/> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="description" class="required">Description: </label> >+ <input type="text" name="description" id="description" size="60" class="required" required="required" value="[%- auth_provider.description | html -%]"/> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="protocol">Protocol: </label> >+ <select name="protocol" id="protocol"> >+ [% IF auth_provider.protocol == 'OAuth' %] >+ <option value="OAuth" selected="selected">OAuth</option> >+ <option value="OIDC">OIDC</option> >+ <!-- Not implemented yet >+ <option value="LDAP">LDAP</option> >+ <option value="CAS">CAS</option> >+ --> >+ [% ELSE %] >+ <option value="OAuth">OAuth</option> >+ <option value="OIDC" selected="selected">OIDC</option> >+ <!-- Not implemented yet >+ <option value="LDAP">LDAP</option> >+ <option value="CAS">CAS</option> >+ --> >+ [% END %] >+ </select> >+ </li> >+ </ol> >+ </fieldset> >+ >+ <fieldset class="rows"> >+ <ol> >+ <li> >+ <div> >+ <label for="config" class="required json">Configuration: </label> >+ <textarea name="config" id="config" class="required">[%- auth_provider.config | html -%]</textarea> >+ <span class="required">Required</span> >+ </div> >+ <div> >+ <label></label> >+ <button class="btn btn-ligth defaults" data-default-target="config" id="default-config">Add default [%- auth_provider.protocol | html -%] configuration</button> >+ </div> >+ </li> >+ <li> >+ <div> >+ <label for="mapping" class="required json">Mapping: </label> >+ <textarea name="mapping" id="mapping" class="required">[%- auth_provider.mapping | html -%]</textarea> >+ <span class="required">Required</span> >+ </div> >+ <div> >+ <label></label> >+ <button class="btn btn-ligth defaults" data-default-target="mapping" id="default-mapping">Add default [%- auth_provider.protocol | html -%] mapping</button> >+ </div> >+ </li> >+ <li> >+ <label for="matchpoint" class="required">matchpoint: </label> >+ <select name="matchpoint" id="matchpoint" class="required"> >+ [%- IF auth_provider.matchpoint == 'email' -%] >+ <option value="email" selected="selected">Email</option> >+ [%- ELSE -%] >+ <option value="email">Email</option> >+ [%- END -%] >+ [%- IF auth_provider.matchpoint == 'userid' -%] >+ <option value="userid" selected="selected">User id</option> >+ [%- ELSE -%] >+ <option value="userid">User id</option> >+ [%- END -%] >+ [%- IF auth_provider.matchpoint == 'cardnumber' -%] >+ <option value="cardnumber" selected="selected">Card number</option> >+ [%- ELSE -%] >+ <option value="cardnumber">Card number</option> >+ [%- END -%] >+ </select> >+ <span class="required">Required</span> >+ </li> >+ <li> >+ <label for="icon_url">Icon URL: </label> >+ <input type="text" name="icon_url" id="icon_url" size="60" value="[%- auth_provider.icon_url | html -%]"/> >+ </li> >+ </ol> >+ </fieldset> >+ <fieldset class="action"> >+ <input type="submit" value="Submit" /> >+ <a class="cancel" href="/cgi-bin/koha/admin/authentication_providers.pl">Cancel</a> >+ </fieldset> >+ </form> >+[% END %] >+ >+[% IF op == 'list' %] >+ >+ <div id="toolbar" class="btn-toolbar"> >+ <a class="btn btn-default" id="new_auth_provider" href="/cgi-bin/koha/admin/authentication_providers.pl?op=add_form"><i class="fa fa-plus"></i> New authentication provider</a> >+ </div> >+ >+ <h1>Authentication providers</h1> >+ >+ <table id="auth_providers"> >+ <thead> >+ <tr> >+ <th>Code</th> >+ <th>Description</th> >+ <th>Protocol</th> >+ <th data-class-name="actions noExport">Actions</th> >+ </tr> >+ </thead> >+ </table> >+[% END %] >+ >+ <div id="delete_confirm_modal" class="modal" tabindex="-1" role="dialog" aria-labelledby="delete_confirm_modal_label" aria-hidden="true"> >+ <div class="modal-dialog"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">Ã</button> >+ <h3 id="delete_confirm_modal_label">Delete authentication provider</h3> >+ </div> >+ <div class="modal-body"> >+ <div id="delete_confirm_dialog"></div> >+ </div> >+ <div class="modal-footer"> >+ <a href="#" class="btn btn-default" id="delete_confirm_modal_button" role="button" data-toggle="modal">Delete</a> >+ <button class="btn btn-default" data-dismiss="modal" aria-hidden="true">Close</button> >+ </div> >+ </div> <!-- /.modal-content --> >+ </div> <!-- /.modal-dialog --> >+ </div> <!-- #delete_confirm_modal --> >+ >+ </main> >+ </div> <!-- /.col-sm-10.col-sm-push-2 --> >+ >+ <div class="col-sm-2 col-sm-pull-10"> >+ <aside> >+ [% INCLUDE 'admin-menu.inc' %] >+ </aside> >+ </div> <!-- /.col-sm-2.col-sm-pull-10 --> >+ </div> <!-- /.row --> >+ >+ >+[% MACRO jsinclude BLOCK %] >+ [% Asset.js("js/admin-menu.js") | $raw %] >+ [% INCLUDE 'datatables.inc' %] >+ <script> >+ $(document).ready(function() { >+ >+ var auth_providers_url = '/api/v1/auth/providers'; >+ window.auth_providers = $("#auth_providers").kohaTable({ >+ "ajax": { >+ "url": auth_providers_url >+ }, >+ 'language': { >+ 'emptyTable': '<div class="dialog message">'+_("There are no authentication providers defined.")+'</div>' >+ }, >+ "columnDefs": [ { >+ "targets": [0,1,2], >+ "render": function (data, type, row, meta) { >+ if ( type == 'display' ) { >+ if ( data != null ) { >+ return data.escapeHtml(); >+ } >+ else { >+ return "Default"; >+ } >+ } >+ return data; >+ } >+ } ], >+ "columns": [ >+ { >+ "data": "code", >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": "description", >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": "protocol", >+ "searchable": true, >+ "orderable": true >+ }, >+ { >+ "data": function( row, type, val, meta ) { >+ var result = '<a class="btn btn-default btn-xs" role="button" href="/cgi-bin/koha/admin/authentication_providers.pl?op=edit_form&auth_provider_id='+ encodeURIComponent(row.auth_provider_id) +'"><i class="fa fa-pencil" aria-hidden="true"></i> '+_("Edit")+'</a>'+"\n"; >+ result += '<a class="btn btn-default btn-xs delete_auth_provider" role="button" href="#" data-toggle="modal" data-target="#delete_confirm_modal" data-auth-provider-id="'+ encodeURIComponent(row.auth_provider_id) +'" data-auth-provider-code="'+ encodeURIComponent(row.code.escapeHtml()) +'"><i class="fa fa-trash" aria-hidden="true"></i> '+_("Delete")+'</a>'+"\n"; >+ result += '<a class="btn btn-default btn-xs edit_domains" role="button" href="/cgi-bin/koha/admin/authentication_providers.pl?domain_ops=1&auth_provider_id='+ encodeURIComponent(row.auth_provider_id) +'"><i class="fa fa-cog" aria-hidden="true"></i> '+_("Manage Domains")+'</a>'; >+ return result; >+ }, >+ "searchable": false, >+ "orderable": false >+ } >+ ], >+ createdRow: function (row, data, dataIndex) { >+ if ( data.debug ) { >+ $(row).addClass('debug'); >+ } >+ }, >+ }); >+ >+ $('#auth_providers').on( "click", '.delete_auth_provider', function () { >+ var auth_provider_id = $(this).data('auth-provider-id'); >+ var auth_provider_code = decodeURIComponent($(this).data('auth-provider-code')); >+ >+ $("#delete_confirm_dialog").html( >+ _("You are about to delete the '%s' authentication provider.").format(auth_provider_code) >+ ); >+ $("#delete_confirm_modal_button").data('auth-provider-id', auth_provider_id); >+ $("#delete_confirm_modal_button").data('auth-provider-code', auth_provider_code); >+ }); >+ >+ $("#delete_confirm_modal_button").on( "click", function () { >+ >+ var auth_provider_id = $(this).data('auth-provider-id'); >+ var auth_provider_code = $(this).data('auth-provider-code'); >+ >+ $.ajax({ >+ method: "DELETE", >+ url: auth_providers_url+"/"+auth_provider_id >+ }).success(function() { >+ window.auth_providers.api().ajax.reload(function (data) { >+ $("#auth_provider_action_result_dialog").hide(); >+ $("#auth_provider_delete_success").html(_("Server '%s' deleted successfully.").format(auth_provider_code)).show(); >+ }); >+ }).fail(function () { >+ $("#auth_provider_delete_error").html(_("Error deleting server '%s'. Check the logs.").format(auth_provider_code)).show(); >+ }).done(function () { >+ $("#delete_confirm_modal").modal('hide'); >+ }); >+ }); >+ >+ $.validator.addMethod('json', function(value, element) { >+ if (this.optional(element)) return true; >+ try { >+ JSON.parse(value) >+ } catch (error) { >+ return false; >+ } >+ return true; >+ }, _('Not a valid JSON')); >+ >+ $('#config, #mapping').each(function() { >+ $(this).rules('add', { >+ required: true, >+ json: true >+ }); >+ }); >+ >+ var defaults = { >+ OIDC: { >+ config: { >+ key: "<enter client id>", >+ secret: "<enter client secret>", >+ well_known_url: "<enter openid configuration endpoint>", >+ scope: "openid email" >+ }, >+ mapping: { >+ email: "email", >+ given_name: "firstname", >+ family_name: "surname" >+ } >+ }, >+ OAuth: { >+ config: { >+ key: "<enter client id>", >+ secret: "<enter client secret>", >+ authorize_url: "<enter authorization endpoint>", >+ token_url: "<enter token endpoint>", >+ userinfo_url: "<enter user info endpoint (optional)>", >+ scope: "email" >+ }, >+ mapping: { >+ email: "email", >+ given_name: "firstname", >+ family_name: "surname" >+ } >+ } >+ }; >+ >+ $('#protocol').on('change', function() { >+ var protocol = $(this).val(); >+ $('#default-config').html(_('Add default %s configuration').format(protocol)); >+ $('#default-mapping').html(_('Add default %s mapping').format(protocol)); >+ }); >+ >+ $('button.defaults').on('click', function(event) { >+ event.preventDefault(); >+ var target = $(this).data('defaultTarget'); >+ if($('#'+target).html() !== '' && !confirm(_('Are you sure you want to replace current %s contents?').format(target))) { >+ return; >+ } >+ var protocol = $('#protocol').val(); >+ $('#'+target).html(JSON.stringify(defaults[protocol][target], null, 2)); >+ }) >+ }); >+ </script> >+[% END %] >+ >+[% INCLUDE 'intranet-bottom.inc' %] >-- >2.34.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 31378
:
141362
|
141363
|
141364
|
141365
|
141366
|
141367
|
141368
|
141369
|
141370
|
141371
|
141372
|
141373
|
141374
|
141375
|
141376
|
141377
|
141378
|
141514
|
141771
|
141772
|
141773
|
141774
|
141775
|
141776
|
141777
|
141778
|
141779
|
141780
|
141781
|
141782
|
141783
|
141784
|
141785
|
141786
|
141787
|
141788
|
141801
|
141802
|
141803
|
141804
|
141805
|
141806
|
141807
|
141808
|
141809
|
141810
|
141811
|
141812
|
141813
|
141814
|
141815
|
141816
|
141817
|
141818
|
141853
|
143056
|
143087
|
143088
|
143089
|
143090
|
143091
|
143092
|
143093
|
143094
|
143095
|
143096
|
143097
|
143098
|
143099
|
143100
|
143101
|
143102
|
143103
|
143104
|
143105
|
143106
|
143107
|
143186
|
143187
|
143188
|
143189
|
143190
|
143191
|
143192
|
143193
|
143194
|
143195
|
143196
|
143197
|
143198
|
143199
|
143200
|
143202
|
143204
|
143205
|
143206
|
143207
|
143208
|
143215
|
143216
|
143217
|
143218
|
143219
|
143220
|
143221
|
143222
|
143223
|
143224
|
143225
|
143226
|
143227
|
143228
|
143229
|
143230
|
143231
|
143232
|
143233
|
143234
|
143235
|
143236
|
143266
|
143267
|
143268
|
143269
|
143270
|
143271
|
143272
|
143273
|
143274
|
143275
|
143277
|
143278
|
143279
|
143280
|
143281
|
143282
|
143283
|
143284
|
143285
|
143286
|
143287
|
143288
|
143396
|
143397
|
143398
|
143399
|
143400
|
143401
|
143402
|
143403
|
143404
|
143405
|
143406
|
143407
|
143408
|
143409
|
143410
|
143411
|
143412
|
143413
|
143414
|
143415
|
143416
|
143417
|
143418
|
143420
|
143421
|
143422
|
143423
|
143424
|
143425
|
143426
|
143427
|
143428
|
143429
|
143430
|
143431
|
143432
|
143433
|
143434
|
143435
|
143436
|
143437
|
143438
|
143439
|
143440
|
143441
|
143442
|
143443
|
143450
|
144071
|
144175