View | Details | Raw Unified | Return to bug 31378
Collapse All | Expand All

(-)a/admin/identity_providers.pl (-18 / +38 lines)
Lines 26-31 use Try::Tiny qw( catch try ); Link Here
26
use C4::Auth qw( get_template_and_user );
26
use C4::Auth qw( get_template_and_user );
27
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output qw( output_html_with_http_headers );
28
28
29
use Koha::Database;
29
use Koha::Auth::Identity::Providers;
30
use Koha::Auth::Identity::Providers;
30
31
31
my $input         = CGI->new;
32
my $input         = CGI->new;
Lines 51-83 my @messages; Link Here
51
52
52
if ( !$domain_ops && $op eq 'add' ) {
53
if ( !$domain_ops && $op eq 'add' ) {
53
54
55
    # IdP configuration params
54
    my $code        = $input->param('code');
56
    my $code        = $input->param('code');
55
    my $config      = $input->param('config');
57
    my $config      = $input->param('config');
56
    my $description = $input->param('description');
58
    my $description = $input->param('description');
57
    my $icon_url    = $input->param('icon_url');
59
    my $icon_url    = $input->param('icon_url');
58
    my $mapping     = $input->param('mapping');
60
    my $mapping     = $input->param('mapping');
59
    my $matchpoint  = $input->param('matchpoint'),
61
    my $matchpoint  = $input->param('matchpoint');
60
    my $protocol    = $input->param('protocol');
62
    my $protocol    = $input->param('protocol');
63
    # Domain configuration params
64
    my $allow_opac          = $input->param('allow_opac') // 0;
65
    my $allow_staff         = $input->param('allow_staff') // 0;
66
    my $auto_register       = $input->param('auto_register') // 0;
67
    my $default_category_id = $input->param('default_category_id');
68
    my $default_library_id  = $input->param('default_library_id');
69
    my $domain              = $input->param('domain');
70
    my $update_on_auth      = $input->param('update_on_$update_on_auth');
61
71
62
    try {
72
    try {
63
        my $provider = Koha::Auth::Identity::Provider->new(
73
        Koha::Database->new->schema->txn_do(
64
            {   code        => $code,
74
            sub {
65
                config      => $config,
75
                my $provider = Koha::Auth::Identity::Provider->new(
66
                description => $description,
76
                    {   code        => $code,
67
                icon_url    => $icon_url,
77
                        config      => $config,
68
                mapping     => $mapping,
78
                        description => $description,
69
                matchpoint  => $matchpoint,
79
                        icon_url    => $icon_url,
70
                protocol    => $protocol,
80
                        mapping     => $mapping,
81
                        matchpoint  => $matchpoint,
82
                        protocol    => $protocol,
83
                    }
84
                )->store;
85
86
                Koha::Auth::Identity::Provider::Domain->new(
87
                    {   identity_provider_id => $provider->identity_provider_id,
88
                        allow_opac           => $allow_opac,
89
                        allow_staff          => $allow_staff,
90
                        auto_register        => $auto_register,
91
                        default_category_id  => $default_category_id,
92
                        default_library_id   => $default_library_id,
93
                        domain               => $domain,
94
                        update_on_auth       => $update_on_auth,
95
                    }
96
                )->store;
97
98
                push @messages, { type => 'message', code => 'success_on_insert' };
71
            }
99
            }
72
        )->store;
100
        );
73
74
        Koha::Auth::Identity::Provider::Domain->new(
75
            {
76
                identity_provider_id => $provider->identity_provider_id,
77
            }
78
        )->store;
79
80
        push @messages, { type => 'message', code => 'success_on_insert' };
81
    }
101
    }
82
    catch {
102
    catch {
83
        if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
103
        if ( blessed $_ and $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_provider_domains.tt (-1 / +1 lines)
Lines 152-158 Link Here
152
                            <option value="1" selected="selected">Allow</option>
152
                            <option value="1" selected="selected">Allow</option>
153
                            <option value="0">Don't allow</option>
153
                            <option value="0">Don't allow</option>
154
                        </select>
154
                        </select>
155
                        <span>opac users of this domain to login with this identity provider</span>
155
                        <span>OPAC users from this domain to login with this identity provider.</span>
156
                    </li>
156
                    </li>
157
                    <li>
157
                    <li>
158
                        <label for="allow_opac">Allow staff: </label>
158
                        <label for="allow_opac">Allow staff: </label>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/identity_providers.tt (-3 / +69 lines)
Lines 1-5 Link Here
1
[% USE raw %]
1
[% USE raw %]
2
[% USE Asset %]
2
[% USE Asset %]
3
[% USE Branches %]
4
[% USE Categories %]
3
[% SET footerjs = 1 %]
5
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
6
[% INCLUDE 'doc-head-open.inc' %]
5
<title>
7
<title>
Lines 87-92 Link Here
87
        <form action="/cgi-bin/koha/admin/identity_providers.pl" id="add" name="add" class="validated" method="post">
89
        <form action="/cgi-bin/koha/admin/identity_providers.pl" id="add" name="add" class="validated" method="post">
88
            <input type="hidden" name="op" value="add" />
90
            <input type="hidden" name="op" value="add" />
89
            <fieldset class="rows">
91
            <fieldset class="rows">
92
                <legend id="identity_provider_basic">Basic configuration</legend>
90
                <ol>
93
                <ol>
91
                    <li>
94
                    <li>
92
                        <label for="code" class="required">Code: </label>
95
                        <label for="code" class="required">Code: </label>
Lines 116-125 Link Here
116
            </fieldset>
119
            </fieldset>
117
120
118
            <fieldset class="rows">
121
            <fieldset class="rows">
122
                <legend id="identity_provider_advanced">Advanced configuration</legend>
119
                <ol>
123
                <ol>
120
                    <li>
124
                    <li>
121
                        <label for="config" class="required json">Configuration: </label>
125
                        <label for="config" class="required json">Configuration: </label>
122
                        <textarea name="config" id="config" class="required"></textarea>
126
                        <textarea name="config" id="config" class="required" cols="75" rows="10"></textarea>
123
                        <span class="required">Required</span>
127
                        <span class="required">Required</span>
124
                        <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>
128
                        <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>
125
                        <div class="hint more-config" style="display: none">
129
                        <div class="hint more-config" style="display: none">
Lines 132-138 Link Here
132
                    </li>
136
                    </li>
133
                    <li>
137
                    <li>
134
                        <label for="mapping" class="required json">Mapping: </label>
138
                        <label for="mapping" class="required json">Mapping: </label>
135
                        <textarea name="mapping" id="mapping" class="required"></textarea>
139
                        <textarea name="mapping" id="mapping" class="required" cols="75" rows="10"></textarea>
136
                        <span class="required">Required</span>
140
                        <span class="required">Required</span>
137
                        <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>
141
                        <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>
138
                        <div class="hint more-mapping" style="display: none">
142
                        <div class="hint more-mapping" style="display: none">
Lines 162-167 Link Here
162
                    </li>
166
                    </li>
163
                </ol>
167
                </ol>
164
            </fieldset>
168
            </fieldset>
169
170
            <fieldset class="rows">
171
                <legend id="identity_provider_domain">Domain configuration</legend>
172
                <ol>
173
                    <li>
174
                        <label for="domain" class="required">Domain: </label>
175
                        <input type="text" name="domain" id="domain" class="required" size="60" />
176
                        <span class="required">Required</span>
177
                        <div class="hint">Use &ast; for any domain. You can add new domains later on the dedicated admin page.</div>
178
                    </li>
179
                    <li>
180
                        <label for="default_library_id">Default library: </label>
181
                        <select id="default_library_id" name="default_library_id" class="mandatory">
182
                            [% PROCESS options_for_libraries libraries => Branches.all( unfiltered => 1, do_not_select_my_library => 1 ) %]
183
                        </select>
184
                        <span class="required">Required</span>
185
                        <div class="hint">Use this library for the patron on auto register</div>
186
                    </li>
187
                    <li>
188
                        <label for="default_category_id">Default category: </label>
189
                        [% SET categories = Categories.all() %]
190
                        <select name="default_category_id" id="default_category_id" class="mandatory">
191
                            [% FOREACH category IN categories %]
192
                                <option value="[% category.categorycode | html %]">[% category.description | html %]</option>
193
                            [% END %]
194
                        </select>
195
                        <span class="required">Required</span>
196
                        <div class="hint">Use this category for the patron on auto register</div>
197
                    </li>
198
                    <li>
199
                        <label for="allow_opac">Allow OPAC: </label>
200
                        <select name="allow_opac" id="allow_opac">
201
                            <option value="1">Yes</option>
202
                            <option value="0" selected="selected">No</option>
203
                        </select>
204
                        <div class="hint">Allow OPAC access to users from this domain to login with this identity provider.</div>
205
                    </li>
206
                    <li>
207
                        <label for="allow_opac">Allow staff: </label>
208
                        <select name="allow_staff" id="allow_staff">
209
                            <option value="1">Yes</option>
210
                            <option value="0" selected="selected">No</option>
211
                        </select>
212
                        <div class="hint">Allow staff access to users from this domain to login with this identity provider.</div>
213
                    </li>
214
                    <li>
215
                        <label for="auto_register">Auto register: </label>
216
                        <select name="auto_register" id="auto_register">
217
                            <option value="1">Yes</option>
218
                            <option value="0" selected="selected">No</option>
219
                        </select>
220
                        <div class="hint">Allow users to auto register on login.</div>
221
                    </li>
222
                    <li>
223
                        <label for="update_on_auth">Update on login: </label>
224
                        <select name="update_on_auth" id="update_on_auth">
225
                            <option value="1">Yes</option>
226
                            <option value="0" selected="selected">No</option>
227
                        </select>
228
                        <div class="hint">Update user data on login.</div>
229
                </ol>
230
            </fieldset>
231
165
            <fieldset class="action">
232
            <fieldset class="action">
166
                <input type="submit" value="Submit" />
233
                <input type="submit" value="Submit" />
167
                <a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl">Cancel</a>
234
                <a class="cancel" href="/cgi-bin/koha/admin/identity_providers.pl">Cancel</a>
168
- 

Return to bug 31378