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

(-)a/Koha/REST/V1/Auth/Hostnames.pm (+76 lines)
Line 0 Link Here
1
package Koha::REST::V1::Auth::Hostnames;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <https://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::Auth::Hostname;
23
use Koha::Auth::Hostnames;
24
25
use Try::Tiny;
26
27
=head1 NAME
28
29
Koha::REST::V1::Auth::Hostnames - Controller library for handling hostname routes.
30
31
=head2 Operations
32
33
=head3 list
34
35
Controller method for listing all known hostnames.
36
37
=cut
38
39
sub list {
40
    my $c = shift->openapi->valid_input or return;
41
42
    return try {
43
        return $c->render(
44
            status  => 200,
45
            openapi => $c->objects->search( Koha::Auth::Hostnames->new ),
46
        );
47
    } catch {
48
        $c->unhandled_exception($_);
49
    };
50
}
51
52
=head3 get
53
54
Controller method for retrieving a single hostname by ID.
55
56
=cut
57
58
sub get {
59
    my $c = shift->openapi->valid_input or return;
60
61
    return try {
62
        my $hostname = $c->objects->find(
63
            Koha::Auth::Hostnames->new,
64
            $c->param('hostname_id')
65
        );
66
67
        return $c->render_resource_not_found("Hostname")
68
            unless $hostname;
69
70
        return $c->render( status => 200, openapi => $hostname );
71
    } catch {
72
        $c->unhandled_exception($_);
73
    };
74
}
75
76
1;
(-)a/Koha/REST/V1/Auth/Identity/Provider/Hostnames.pm (+239 lines)
Line 0 Link Here
1
package Koha::REST::V1::Auth::Identity::Provider::Hostnames;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <https://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::Auth::Hostname;
23
use Koha::Auth::Hostnames;
24
use Koha::Auth::Identity::Provider::Hostname;
25
use Koha::Auth::Identity::Provider::Hostnames;
26
use Koha::Auth::Identity::Providers;
27
28
use Koha::Database;
29
30
use Scalar::Util qw(blessed);
31
use Try::Tiny;
32
33
=head1 NAME
34
35
Koha::REST::V1::Auth::Identity::Provider::Hostnames - Controller library for handling
36
identity provider hostname routes.
37
38
Each row is a many-to-many association between a hostname (via hostname_id FK) and an
39
identity provider. The unique constraint is on (hostname_id, identity_provider_id).
40
41
=head2 Operations
42
43
=head3 list
44
45
Controller method for listing identity provider hostnames.
46
47
=cut
48
49
sub list {
50
    my $c = shift->openapi->valid_input or return;
51
52
    return try {
53
        my $provider = Koha::Auth::Identity::Providers->find( $c->param('identity_provider_id') );
54
55
        return $c->render_resource_not_found("Identity provider")
56
            unless $provider;
57
58
        my $hostnames_rs = $provider->hostnames;
59
        return $c->render(
60
            status  => 200,
61
            openapi => $c->objects->search($hostnames_rs),
62
        );
63
    } catch {
64
        $c->unhandled_exception($_);
65
    };
66
}
67
68
=head3 get
69
70
Controller method for retrieving an identity provider hostname.
71
72
=cut
73
74
sub get {
75
    my $c = shift->openapi->valid_input or return;
76
77
    return try {
78
        my $provider = Koha::Auth::Identity::Providers->find( $c->param('identity_provider_id') );
79
80
        return $c->render_resource_not_found("Identity provider")
81
            unless $provider;
82
83
        my $hostnames_rs = $provider->hostnames;
84
85
        my $hostname = $c->objects->find(
86
            $hostnames_rs,
87
            $c->param('identity_provider_hostname_id')
88
        );
89
90
        return $c->render_resource_not_found("Identity provider hostname")
91
            unless $hostname;
92
93
        return $c->render( status => 200, openapi => $hostname );
94
    } catch {
95
        $c->unhandled_exception($_);
96
    }
97
}
98
99
=head3 add
100
101
Controller method for adding an identity provider hostname.
102
103
Accepts either a C<hostname_id> integer (direct FK reference) or a C<hostname>
104
string (the backend will find-or-create the canonical hostname record and resolve
105
it to a C<hostname_id> before creating the bridge row).
106
107
=cut
108
109
sub add {
110
    my $c = shift->openapi->valid_input or return;
111
112
    return try {
113
        my $provider = Koha::Auth::Identity::Providers->find( $c->param('identity_provider_id') );
114
115
        return $c->render_resource_not_found("Identity provider")
116
            unless $provider;
117
118
        Koha::Database->new->schema->txn_do(
119
            sub {
120
                my $body = $c->req->json;
121
                $body->{identity_provider_id} = $c->param('identity_provider_id');
122
123
                # If caller sent a hostname string instead of hostname_id,
124
                # resolve it via find_or_create on the hostnames table.
125
                unless ( $body->{hostname_id} ) {
126
                    my $hostname_str = delete $body->{hostname};
127
                    my $hostname_rec = Koha::Auth::Hostnames->search( { hostname => $hostname_str } )->next
128
                        // Koha::Auth::Hostname->new( { hostname => $hostname_str } )->store;
129
                    $body->{hostname_id} = $hostname_rec->hostname_id;
130
                } else {
131
132
                    # hostname string is readOnly in the schema; strip it if present
133
                    delete $body->{hostname};
134
                }
135
136
                my $hostname = Koha::Auth::Identity::Provider::Hostname->new_from_api($body);
137
                $hostname->store;
138
139
                $c->res->headers->location( $c->req->url->to_string . '/' . $hostname->id );
140
                return $c->render(
141
                    status  => 201,
142
                    openapi => $c->objects->to_api($hostname),
143
                );
144
            }
145
        );
146
    } catch {
147
        if ( blessed($_) and $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
148
            return $c->render(
149
                status  => 409,
150
                openapi => {
151
                    error      => 'A hostname entry with this hostname already exists for this provider',
152
                    error_code => 'duplicate_hostname',
153
                }
154
            );
155
        }
156
157
        $c->unhandled_exception($_);
158
    };
159
}
160
161
=head3 update
162
163
Controller method for updating an identity provider hostname.
164
165
=cut
166
167
sub update {
168
    my $c = shift->openapi->valid_input or return;
169
170
    my $hostname = Koha::Auth::Identity::Provider::Hostnames->find(
171
        {
172
            identity_provider_id          => $c->param('identity_provider_id'),
173
            identity_provider_hostname_id => $c->param('identity_provider_hostname_id'),
174
        }
175
    );
176
177
    return $c->render_resource_not_found("Identity provider hostname")
178
        unless $hostname;
179
180
    return try {
181
        Koha::Database->new->schema->txn_do(
182
            sub {
183
                my $body = $c->req->json;
184
185
                # hostname string is readOnly; strip it to avoid set_from_api errors
186
                delete $body->{hostname};
187
188
                $hostname->set_from_api($body);
189
                $hostname->store->discard_changes;
190
191
                return $c->render(
192
                    status  => 200,
193
                    openapi => $c->objects->to_api($hostname),
194
                );
195
            }
196
        );
197
    } catch {
198
        if ( blessed($_) and $_->isa('Koha::Exceptions::Object::DuplicateID') ) {
199
            return $c->render(
200
                status  => 409,
201
                openapi => {
202
                    error      => 'A hostname entry with this hostname already exists for this provider',
203
                    error_code => 'duplicate_hostname',
204
                }
205
            );
206
        }
207
208
        $c->unhandled_exception($_);
209
    };
210
}
211
212
=head3 delete
213
214
Controller method for deleting an identity provider hostname.
215
216
=cut
217
218
sub delete {
219
    my $c = shift->openapi->valid_input or return;
220
221
    my $hostname = Koha::Auth::Identity::Provider::Hostnames->find(
222
        {
223
            identity_provider_id          => $c->param('identity_provider_id'),
224
            identity_provider_hostname_id => $c->param('identity_provider_hostname_id'),
225
        }
226
    );
227
228
    return $c->render_resource_not_found("Identity provider hostname")
229
        unless $hostname;
230
231
    return try {
232
        $hostname->delete;
233
        return $c->render_resource_deleted;
234
    } catch {
235
        $c->unhandled_exception($_);
236
    };
237
}
238
239
1;
(-)a/Koha/REST/V1/Auth/Identity/Provider/Mappings.pm (+210 lines)
Line 0 Link Here
1
package Koha::REST::V1::Auth::Identity::Provider::Mappings;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <https://www.gnu.org/licenses>.
17
18
use Modern::Perl;
19
20
use Mojo::Base 'Mojolicious::Controller';
21
22
use Koha::Auth::Identity::Provider::Mapping;
23
use Koha::Auth::Identity::Provider::Mappings;
24
use Koha::Auth::Identity::Providers;
25
26
use Koha::Database;
27
28
use Scalar::Util qw(blessed);
29
use Try::Tiny;
30
31
=head1 NAME
32
33
Koha::REST::V1::Auth::Identity::Provider::Mappings - Controller for identity
34
provider field mapping routes.
35
36
=head2 Operations
37
38
=head3 list
39
40
Controller method for listing field mappings for an identity provider.
41
42
=cut
43
44
sub list {
45
    my $c = shift->openapi->valid_input or return;
46
47
    return try {
48
        my $provider = Koha::Auth::Identity::Providers->find( $c->param('identity_provider_id') );
49
50
        return $c->render_resource_not_found("Identity provider")
51
            unless $provider;
52
53
        my $mappings_rs = $provider->mappings;
54
        return $c->render(
55
            status  => 200,
56
            openapi => $c->objects->search($mappings_rs)
57
        );
58
    } catch {
59
        $c->unhandled_exception($_);
60
    };
61
}
62
63
=head3 get
64
65
Controller method for retrieving a single field mapping.
66
67
=cut
68
69
sub get {
70
    my $c = shift->openapi->valid_input or return;
71
72
    return try {
73
        my $provider = Koha::Auth::Identity::Providers->find( $c->param('identity_provider_id') );
74
75
        return $c->render_resource_not_found("Identity provider")
76
            unless $provider;
77
78
        my $mapping = $c->objects->find(
79
            $provider->mappings,
80
            $c->param('identity_provider_mapping_id')
81
        );
82
83
        return $c->render_resource_not_found("Identity provider mapping")
84
            unless $mapping;
85
86
        return $c->render( status => 200, openapi => $mapping );
87
    } catch {
88
        $c->unhandled_exception($_);
89
    };
90
}
91
92
=head3 add
93
94
Controller method for adding a field mapping to an identity provider.
95
96
=cut
97
98
sub add {
99
    my $c = shift->openapi->valid_input or return;
100
101
    return try {
102
        my $provider = Koha::Auth::Identity::Providers->find( $c->param('identity_provider_id') );
103
104
        return $c->render_resource_not_found("Identity provider")
105
            unless $provider;
106
107
        Koha::Database->new->schema->txn_do(
108
            sub {
109
                my $params = $c->req->json;
110
                $params->{identity_provider_id} = $c->param('identity_provider_id');
111
112
                my $mapping = Koha::Auth::Identity::Provider::Mapping->new_from_api($params);
113
                $mapping->store;
114
115
                $c->res->headers->location( $c->req->url->to_string . '/' . $mapping->id );
116
                return $c->render(
117
                    status  => 201,
118
                    openapi => $c->objects->to_api($mapping),
119
                );
120
            }
121
        );
122
    } catch {
123
        if ( blessed($_) and $_->isa('Koha::Exceptions::MissingParameter') ) {
124
            return $c->render(
125
                status  => 400,
126
                openapi => {
127
                    error      => 'Missing parameter: ' . $_->parameter,
128
                    error_code => 'missing_parameter',
129
                }
130
            );
131
        }
132
133
        $c->unhandled_exception($_);
134
    };
135
}
136
137
=head3 update
138
139
Controller method for updating a field mapping.
140
141
=cut
142
143
sub update {
144
    my $c = shift->openapi->valid_input or return;
145
146
    my $mapping = Koha::Auth::Identity::Provider::Mappings->find(
147
        {
148
            identity_provider_id => $c->param('identity_provider_id'),
149
            mapping_id           => $c->param('identity_provider_mapping_id'),
150
        }
151
    );
152
153
    return $c->render_resource_not_found("Identity provider mapping")
154
        unless $mapping;
155
156
    return try {
157
        Koha::Database->new->schema->txn_do(
158
            sub {
159
                $mapping->set_from_api( $c->req->json );
160
                $mapping->store->discard_changes;
161
162
                return $c->render(
163
                    status  => 200,
164
                    openapi => $c->objects->to_api($mapping),
165
                );
166
            }
167
        );
168
    } catch {
169
        if ( blessed($_) and $_->isa('Koha::Exceptions::MissingParameter') ) {
170
            return $c->render(
171
                status  => 400,
172
                openapi => {
173
                    error      => 'Missing parameter: ' . $_->parameter,
174
                    error_code => 'missing_parameter',
175
                }
176
            );
177
        }
178
179
        $c->unhandled_exception($_);
180
    };
181
}
182
183
=head3 delete
184
185
Controller method for deleting a field mapping.
186
187
=cut
188
189
sub delete {
190
    my $c = shift->openapi->valid_input or return;
191
192
    my $mapping = Koha::Auth::Identity::Provider::Mappings->find(
193
        {
194
            identity_provider_id => $c->param('identity_provider_id'),
195
            mapping_id           => $c->param('identity_provider_mapping_id'),
196
        }
197
    );
198
199
    return $c->render_resource_not_found("Identity provider mapping")
200
        unless $mapping;
201
202
    return try {
203
        $mapping->delete;
204
        return $c->render_resource_deleted;
205
    } catch {
206
        $c->unhandled_exception($_);
207
    };
208
}
209
210
1;
(-)a/Koha/REST/V1/Auth/Identity/Providers.pm (-9 / +9 lines)
Lines 19-26 use Modern::Perl; Link Here
19
19
20
use Mojo::Base 'Mojolicious::Controller';
20
use Mojo::Base 'Mojolicious::Controller';
21
21
22
use Koha::Auth::Identity::Provider::OAuth;
23
use Koha::Auth::Identity::Provider::OIDC;
24
use Koha::Auth::Identity::Providers;
22
use Koha::Auth::Identity::Providers;
25
23
26
use Koha::Database;
24
use Koha::Database;
Lines 94-105 sub add { Link Here
94
                my $body = $c->req->json;
92
                my $body = $c->req->json;
95
93
96
                my $config   = delete $body->{config};
94
                my $config   = delete $body->{config};
97
                my $mapping  = delete $body->{mapping};
98
                my $protocol = delete $body->{protocol};
95
                my $protocol = delete $body->{protocol};
99
96
100
                my $class = Koha::Auth::Identity::Provider::protocol_to_class_mapping->{$protocol};
97
                my $class = Koha::Auth::Identity::Providers->new->_polymorphic_map->{$protocol};
101
98
102
                my $provider = $class->new_from_api($body)->set_config($config)->set_mapping($mapping)->store;
99
                Koha::Exception->throw("$protocol is not a valid protocol") unless $class;
100
101
                my $provider = $class->new_from_api($body)->set_config($config)->store;
103
102
104
                $c->res->headers->location( $c->req->url->to_string . '/' . $provider->identity_provider_id );
103
                $c->res->headers->location( $c->req->url->to_string . '/' . $provider->identity_provider_id );
105
                return $c->render(
104
                return $c->render(
Lines 146-157 sub update { Link Here
146
145
147
                my $body = $c->req->json;
146
                my $body = $c->req->json;
148
147
149
                my $config  = delete $body->{config};
148
                my $config = delete $body->{config};
150
                my $mapping = delete $body->{mapping};
151
149
152
                $provider = $provider->set_from_api($body)->upgrade_class;
150
                $provider->set_from_api($body);
151
                $provider = Koha::Auth::Identity::Providers->new->object_class( $provider->_result )
152
                    ->_new_from_dbic( $provider->_result );
153
153
154
                $provider->set_config($config)->set_mapping($mapping)->store;
154
                $provider->set_config($config)->store;
155
155
156
                $provider->discard_changes;
156
                $provider->discard_changes;
157
157
(-)a/api/v1/swagger/definitions/hostname.yaml (+13 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  hostname_id:
5
    description: Internally assigned identifier for this hostname
6
    type: integer
7
    readOnly: true
8
  hostname:
9
    description: Server hostname string (matches SERVER_NAME)
10
    type: string
11
additionalProperties: false
12
required:
13
  - hostname
(-)a/api/v1/swagger/definitions/identity_provider.yaml (-17 / +19 lines)
Lines 17-49 properties: Link Here
17
    enum:
17
    enum:
18
      - OAuth
18
      - OAuth
19
      - OIDC
19
      - OIDC
20
      - CAS (not implemented)
20
      - SAML2
21
      - LDAP (not implemented)
21
  config:
22
  mapping:
22
    description: Protocol-specific configuration
23
    description: Attribute mapping
24
    type:
23
    type:
25
      - object
24
      - object
26
      - "null"
25
      - "null"
27
  matchpoint:
28
    description: Patron attribute that will be used to match
29
    type: string
30
    enum:
31
      - email
32
      - userid
33
      - cardnumber
34
  config:
35
    description: Configuration
36
    type: object
37
  icon_url:
26
  icon_url:
38
    description: Icon url
27
    description: Icon url for display on login buttons
39
    type:
28
    type:
40
     - string
29
      - string
41
     - "null"
30
      - "null"
31
  enabled:
32
    description: Whether this provider is active
33
    type: boolean
42
  domains:
34
  domains:
43
    description: Configured domains for the identity provider
35
    description: Configured domains for the identity provider
44
    type:
36
    type:
45
      - array
37
      - array
46
      - "null"
38
      - "null"
39
  hostnames:
40
    description: Configured hostnames for the identity provider
41
    type:
42
      - array
43
      - "null"
44
  mappings:
45
    description: Configured mappings for the identity provider
46
    type:
47
      - array
48
      - "null"
47
additionalProperties: false
49
additionalProperties: false
48
required:
50
required:
49
  - config
51
  - config
(-)a/api/v1/swagger/definitions/identity_provider_domain.yaml (+4 lines)
Lines 38-43 properties: Link Here
38
  allow_staff:
38
  allow_staff:
39
    description: If this domain can be used for staff login
39
    description: If this domain can be used for staff login
40
    type: boolean
40
    type: boolean
41
  send_welcome_email:
42
    description: Send welcome email to patron on first login via this domain
43
    type: boolean
41
additionalProperties: false
44
additionalProperties: false
42
required:
45
required:
43
  - identity_provider_domain_id
46
  - identity_provider_domain_id
Lines 49-51 required: Link Here
49
  - default_category_id
52
  - default_category_id
50
  - allow_opac
53
  - allow_opac
51
  - allow_staff
54
  - allow_staff
55
  - send_welcome_email
(-)a/api/v1/swagger/definitions/identity_provider_hostname.yaml (+28 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  identity_provider_hostname_id:
5
    type: integer
6
    description: Internally assigned identifier for this hostname-provider association
7
    readOnly: true
8
  hostname_id:
9
    description: Identifier of the associated hostname record
10
    type: integer
11
  hostname:
12
    description: >
13
      Server hostname string. When creating a new association, supply either
14
      this field (the backend will find-or-create the canonical hostname record)
15
      or hostname_id. In responses this field is always populated.
16
    type: string
17
  identity_provider_id:
18
    description: Identity provider associated with this hostname
19
    type: integer
20
  is_enabled:
21
    description: Whether this hostname is active for this provider
22
    type: boolean
23
  force_sso:
24
    description: >
25
      Force SSO redirect for users visiting this hostname. Only one
26
      identity provider should have this enabled per hostname.
27
    type: boolean
28
additionalProperties: false
(-)a/api/v1/swagger/definitions/identity_provider_mapping.yaml (+30 lines)
Line 0 Link Here
1
---
2
type: object
3
properties:
4
  mapping_id:
5
    type: integer
6
    description: Internally assigned mapping identifier
7
    readOnly: true
8
  identity_provider_id:
9
    type: integer
10
    description: Reference to identity provider
11
    readOnly: true
12
  provider_field:
13
    type:
14
      - string
15
      - "null"
16
    description: Attribute name from the identity provider
17
  koha_field:
18
    type: string
19
    description: Corresponding field in Koha borrowers table
20
  default_content:
21
    type:
22
      - string
23
      - "null"
24
    description: Default value to use if the provider does not supply this attribute
25
  is_matchpoint:
26
    type: boolean
27
    description: Use this field to match existing patrons (only one per provider)
28
additionalProperties: false
29
required:
30
  - koha_field
(-)a/api/v1/swagger/paths/auth.yaml (+500 lines)
Lines 616-621 Link Here
616
          type: string
616
          type: string
617
          enum:
617
          enum:
618
            - domains
618
            - domains
619
            - hostnames
620
            - mappings
619
        collectionFormat: csv
621
        collectionFormat: csv
620
    produces:
622
    produces:
621
      - application/json
623
      - application/json
Lines 731-736 Link Here
731
          type: string
733
          type: string
732
          enum:
734
          enum:
733
            - domains
735
            - domains
736
            - hostnames
737
            - mappings
734
        collectionFormat: csv
738
        collectionFormat: csv
735
    produces:
739
    produces:
736
      - application/json
740
      - application/json
Lines 1104-1109 Link Here
1104
    x-koha-authorization:
1108
    x-koha-authorization:
1105
      permissions:
1109
      permissions:
1106
        parameters: manage_identity_providers
1110
        parameters: manage_identity_providers
1111
"/auth/identity_providers/{identity_provider_id}/mappings":
1112
  get:
1113
    x-mojo-to: Auth::Identity::Provider::Mappings#list
1114
    operationId: listIdentityProviderMappings
1115
    tags:
1116
      - identity_providers
1117
    summary: List field mappings for an identity provider
1118
    parameters:
1119
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1120
      - $ref: ../swagger.yaml#/parameters/match
1121
      - $ref: ../swagger.yaml#/parameters/order_by
1122
      - $ref: ../swagger.yaml#/parameters/page
1123
      - $ref: ../swagger.yaml#/parameters/per_page
1124
      - $ref: ../swagger.yaml#/parameters/q_param
1125
      - $ref: ../swagger.yaml#/parameters/q_body
1126
      - $ref: ../swagger.yaml#/parameters/request_id_header
1127
    produces:
1128
      - application/json
1129
    responses:
1130
      "200":
1131
        description: List of field mappings
1132
        schema:
1133
          type: array
1134
          items:
1135
            $ref: ../swagger.yaml#/definitions/identity_provider_mapping
1136
      "400":
1137
        description: |
1138
          Bad request. Possible `error_code` attribute values:
1139
1140
            * `invalid_query`
1141
        schema:
1142
          $ref: ../swagger.yaml#/definitions/error
1143
      "403":
1144
        description: Access forbidden
1145
        schema:
1146
          $ref: ../swagger.yaml#/definitions/error
1147
      "404":
1148
        description: Identity provider not found
1149
        schema:
1150
          $ref: ../swagger.yaml#/definitions/error
1151
    x-koha-authorization:
1152
      permissions:
1153
        parameters: manage_identity_providers
1154
  post:
1155
    x-mojo-to: Auth::Identity::Provider::Mappings#add
1156
    operationId: addIdentityProviderMapping
1157
    tags:
1158
      - identity_providers
1159
    summary: Add a field mapping to an identity provider
1160
    parameters:
1161
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1162
      - name: body
1163
        in: body
1164
        description: A field mapping object
1165
        required: true
1166
        schema:
1167
          $ref: ../swagger.yaml#/definitions/identity_provider_mapping
1168
    produces:
1169
      - application/json
1170
    responses:
1171
      "201":
1172
        description: The created field mapping
1173
        schema:
1174
          $ref: ../swagger.yaml#/definitions/identity_provider_mapping
1175
      "400":
1176
        description: Bad request
1177
        schema:
1178
          $ref: ../swagger.yaml#/definitions/error
1179
      "403":
1180
        description: Access forbidden
1181
        schema:
1182
          $ref: ../swagger.yaml#/definitions/error
1183
      "404":
1184
        description: Identity provider not found
1185
        schema:
1186
          $ref: ../swagger.yaml#/definitions/error
1187
    x-koha-authorization:
1188
      permissions:
1189
        parameters: manage_identity_providers
1190
"/auth/identity_providers/{identity_provider_id}/mappings/{identity_provider_mapping_id}":
1191
  get:
1192
    x-mojo-to: Auth::Identity::Provider::Mappings#get
1193
    operationId: getIdentityProviderMapping
1194
    tags:
1195
      - identity_providers
1196
    summary: Get a field mapping
1197
    parameters:
1198
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1199
      - $ref: ../swagger.yaml#/parameters/identity_provider_mapping_id_pp
1200
    produces:
1201
      - application/json
1202
    responses:
1203
      "200":
1204
        description: A field mapping
1205
        schema:
1206
          $ref: ../swagger.yaml#/definitions/identity_provider_mapping
1207
      "400":
1208
        description: Bad request
1209
        schema:
1210
          $ref: ../swagger.yaml#/definitions/error
1211
      "403":
1212
        description: Access forbidden
1213
        schema:
1214
          $ref: ../swagger.yaml#/definitions/error
1215
      "404":
1216
        description: Mapping not found
1217
        schema:
1218
          $ref: ../swagger.yaml#/definitions/error
1219
    x-koha-authorization:
1220
      permissions:
1221
        parameters: manage_identity_providers
1222
  put:
1223
    x-mojo-to: Auth::Identity::Provider::Mappings#update
1224
    operationId: updateIdentityProviderMapping
1225
    tags:
1226
      - identity_providers
1227
    summary: Update a field mapping
1228
    parameters:
1229
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1230
      - $ref: ../swagger.yaml#/parameters/identity_provider_mapping_id_pp
1231
      - name: body
1232
        in: body
1233
        description: Updated mapping object
1234
        required: true
1235
        schema:
1236
          $ref: ../swagger.yaml#/definitions/identity_provider_mapping
1237
    produces:
1238
      - application/json
1239
    responses:
1240
      "200":
1241
        description: Updated field mapping
1242
        schema:
1243
          $ref: ../swagger.yaml#/definitions/identity_provider_mapping
1244
      "400":
1245
        description: Bad request
1246
        schema:
1247
          $ref: ../swagger.yaml#/definitions/error
1248
      "403":
1249
        description: Access forbidden
1250
        schema:
1251
          $ref: ../swagger.yaml#/definitions/error
1252
      "404":
1253
        description: Mapping not found
1254
        schema:
1255
          $ref: ../swagger.yaml#/definitions/error
1256
    x-koha-authorization:
1257
      permissions:
1258
        parameters: manage_identity_providers
1259
  delete:
1260
    x-mojo-to: Auth::Identity::Provider::Mappings#delete
1261
    operationId: delIdentityProviderMapping
1262
    tags:
1263
      - identity_providers
1264
    summary: Delete a field mapping
1265
    parameters:
1266
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1267
      - $ref: ../swagger.yaml#/parameters/identity_provider_mapping_id_pp
1268
    produces:
1269
      - application/json
1270
    responses:
1271
      "204":
1272
        description: Field mapping deleted
1273
      "400":
1274
        description: Bad request
1275
        schema:
1276
          $ref: ../swagger.yaml#/definitions/error
1277
      "403":
1278
        description: Access forbidden
1279
        schema:
1280
          $ref: ../swagger.yaml#/definitions/error
1281
      "404":
1282
        description: Mapping not found
1283
        schema:
1284
          $ref: ../swagger.yaml#/definitions/error
1285
    x-koha-authorization:
1286
      permissions:
1287
        parameters: manage_identity_providers
1107
"/auth/password/validation":
1288
"/auth/password/validation":
1108
  post:
1289
  post:
1109
    x-mojo-to: Auth::Password#validate
1290
    x-mojo-to: Auth::Password#validate
Lines 1184-1186 Link Here
1184
    x-koha-authorization:
1365
    x-koha-authorization:
1185
      permissions:
1366
      permissions:
1186
        borrowers: api_validate_password
1367
        borrowers: api_validate_password
1368
"/auth/identity_providers/{identity_provider_id}/hostnames":
1369
  get:
1370
    x-mojo-to: Auth::Identity::Provider::Hostnames#list
1371
    operationId: listIdentityProviderHostnames
1372
    tags:
1373
      - identity_providers
1374
    summary: List identity provider hostnames
1375
    parameters:
1376
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1377
      - $ref: ../swagger.yaml#/parameters/match
1378
      - $ref: ../swagger.yaml#/parameters/order_by
1379
      - $ref: ../swagger.yaml#/parameters/page
1380
      - $ref: ../swagger.yaml#/parameters/per_page
1381
      - $ref: ../swagger.yaml#/parameters/q_param
1382
      - $ref: ../swagger.yaml#/parameters/q_body
1383
      - $ref: ../swagger.yaml#/parameters/request_id_header
1384
    produces:
1385
      - application/json
1386
    responses:
1387
      "200":
1388
        description: A list of identity provider hostnames
1389
        schema:
1390
          type: array
1391
          items:
1392
            $ref: ../swagger.yaml#/definitions/identity_provider_hostname
1393
      "400":
1394
        description: |
1395
          Bad request. Possible `error_code` attribute values:
1396
1397
            * `invalid_query`
1398
        schema:
1399
          $ref: "../swagger.yaml#/definitions/error"
1400
      "404":
1401
        description: Object not found
1402
        schema:
1403
          $ref: ../swagger.yaml#/definitions/error
1404
      "500":
1405
        description: |
1406
          Internal server error. Possible `error_code` attribute values:
1407
1408
          * `internal_server_error`
1409
        schema:
1410
          $ref: ../swagger.yaml#/definitions/error
1411
      "503":
1412
        description: Under maintenance
1413
        schema:
1414
          $ref: ../swagger.yaml#/definitions/error
1415
    x-koha-authorization:
1416
      permissions:
1417
        parameters: manage_identity_providers
1418
  post:
1419
    x-mojo-to: Auth::Identity::Provider::Hostnames#add
1420
    operationId: addIdentityProviderHostname
1421
    tags:
1422
      - identity_providers
1423
    summary: Add an identity provider hostname
1424
    parameters:
1425
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1426
      - name: body
1427
        in: body
1428
        description: An identity provider hostname object
1429
        required: true
1430
        schema:
1431
          $ref: ../swagger.yaml#/definitions/identity_provider_hostname
1432
    produces:
1433
      - application/json
1434
    responses:
1435
      "201":
1436
        description: Created identity provider hostname
1437
        schema:
1438
          $ref: ../swagger.yaml#/definitions/identity_provider_hostname
1439
      "400":
1440
        description: Bad request
1441
        schema:
1442
          $ref: ../swagger.yaml#/definitions/error
1443
      "403":
1444
        description: Access forbidden
1445
        schema:
1446
          $ref: ../swagger.yaml#/definitions/error
1447
      "404":
1448
        description: Identity provider not found
1449
        schema:
1450
          $ref: ../swagger.yaml#/definitions/error
1451
      "409":
1452
        description: Conflict - hostname already exists
1453
        schema:
1454
          $ref: ../swagger.yaml#/definitions/error
1455
      "500":
1456
        description: |
1457
          Internal server error. Possible `error_code` attribute values:
1458
1459
          * `internal_server_error`
1460
        schema:
1461
          $ref: ../swagger.yaml#/definitions/error
1462
      "503":
1463
        description: Under maintenance
1464
        schema:
1465
          $ref: ../swagger.yaml#/definitions/error
1466
    x-koha-authorization:
1467
      permissions:
1468
        parameters: manage_identity_providers
1469
"/auth/identity_providers/{identity_provider_id}/hostnames/{identity_provider_hostname_id}":
1470
  get:
1471
    x-mojo-to: Auth::Identity::Provider::Hostnames#get
1472
    operationId: getIdentityProviderHostname
1473
    tags:
1474
      - identity_providers
1475
    summary: Get an identity provider hostname
1476
    parameters:
1477
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1478
      - $ref: ../swagger.yaml#/parameters/identity_provider_hostname_id_pp
1479
    produces:
1480
      - application/json
1481
    responses:
1482
      "200":
1483
        description: An identity provider hostname
1484
        schema:
1485
          $ref: ../swagger.yaml#/definitions/identity_provider_hostname
1486
      "400":
1487
        description: Bad request
1488
        schema:
1489
          $ref: "../swagger.yaml#/definitions/error"
1490
      "404":
1491
        description: Object not found
1492
        schema:
1493
          $ref: ../swagger.yaml#/definitions/error
1494
      "500":
1495
        description: |
1496
          Internal server error. Possible `error_code` attribute values:
1497
1498
          * `internal_server_error`
1499
        schema:
1500
          $ref: ../swagger.yaml#/definitions/error
1501
      "503":
1502
        description: Under maintenance
1503
        schema:
1504
          $ref: ../swagger.yaml#/definitions/error
1505
    x-koha-authorization:
1506
      permissions:
1507
        parameters: manage_identity_providers
1508
  put:
1509
    x-mojo-to: Auth::Identity::Provider::Hostnames#update
1510
    operationId: updateIdentityProviderHostname
1511
    tags:
1512
      - identity_providers
1513
    summary: Update an identity provider hostname
1514
    parameters:
1515
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1516
      - $ref: ../swagger.yaml#/parameters/identity_provider_hostname_id_pp
1517
      - name: body
1518
        in: body
1519
        description: An identity provider hostname object
1520
        required: true
1521
        schema:
1522
          $ref: ../swagger.yaml#/definitions/identity_provider_hostname
1523
    produces:
1524
      - application/json
1525
    responses:
1526
      "200":
1527
        description: Updated identity provider hostname
1528
        schema:
1529
          $ref: ../swagger.yaml#/definitions/identity_provider_hostname
1530
      "400":
1531
        description: Bad request
1532
        schema:
1533
          $ref: ../swagger.yaml#/definitions/error
1534
      "403":
1535
        description: Access forbidden
1536
        schema:
1537
          $ref: ../swagger.yaml#/definitions/error
1538
      "404":
1539
        description: Object not found
1540
        schema:
1541
          $ref: ../swagger.yaml#/definitions/error
1542
      "409":
1543
        description: Conflict - hostname already exists
1544
        schema:
1545
          $ref: ../swagger.yaml#/definitions/error
1546
      "500":
1547
        description: |
1548
          Internal server error. Possible `error_code` attribute values:
1549
1550
          * `internal_server_error`
1551
        schema:
1552
          $ref: ../swagger.yaml#/definitions/error
1553
      "503":
1554
        description: Under maintenance
1555
        schema:
1556
          $ref: ../swagger.yaml#/definitions/error
1557
    x-koha-authorization:
1558
      permissions:
1559
        parameters: manage_identity_providers
1560
  delete:
1561
    x-mojo-to: Auth::Identity::Provider::Hostnames#delete
1562
    operationId: deleteIdentityProviderHostname
1563
    tags:
1564
      - identity_providers
1565
    summary: Delete an identity provider hostname
1566
    parameters:
1567
      - $ref: ../swagger.yaml#/parameters/identity_provider_id_pp
1568
      - $ref: ../swagger.yaml#/parameters/identity_provider_hostname_id_pp
1569
    produces:
1570
      - application/json
1571
    responses:
1572
      "204":
1573
        description: Identity provider hostname deleted
1574
      "400":
1575
        description: Bad request
1576
        schema:
1577
          $ref: "../swagger.yaml#/definitions/error"
1578
      "401":
1579
        description: Authentication required
1580
        schema:
1581
          $ref: ../swagger.yaml#/definitions/error
1582
      "403":
1583
        description: Access forbidden
1584
        schema:
1585
          $ref: ../swagger.yaml#/definitions/error
1586
      "404":
1587
        description: Object not found
1588
        schema:
1589
          $ref: ../swagger.yaml#/definitions/error
1590
      "500":
1591
        description: |
1592
          Internal server error. Possible `error_code` attribute values:
1593
1594
          * `internal_server_error`
1595
        schema:
1596
          $ref: ../swagger.yaml#/definitions/error
1597
      "503":
1598
        description: Under maintenance
1599
        schema:
1600
          $ref: ../swagger.yaml#/definitions/error
1601
    x-koha-authorization:
1602
      permissions:
1603
        parameters: manage_identity_providers
1604
/auth/hostnames:
1605
  get:
1606
    x-mojo-to: Auth::Hostnames#list
1607
    operationId: listHostnames
1608
    tags:
1609
      - identity_providers
1610
    summary: List all known hostnames
1611
    parameters:
1612
      - $ref: ../swagger.yaml#/parameters/match
1613
      - $ref: ../swagger.yaml#/parameters/order_by
1614
      - $ref: ../swagger.yaml#/parameters/page
1615
      - $ref: ../swagger.yaml#/parameters/per_page
1616
      - $ref: ../swagger.yaml#/parameters/q_param
1617
      - $ref: ../swagger.yaml#/parameters/q_body
1618
      - $ref: ../swagger.yaml#/parameters/request_id_header
1619
    produces:
1620
      - application/json
1621
    responses:
1622
      "200":
1623
        description: A list of hostnames
1624
        schema:
1625
          type: array
1626
          items:
1627
            $ref: ../swagger.yaml#/definitions/hostname
1628
      "400":
1629
        description: |
1630
          Bad request. Possible `error_code` attribute values:
1631
1632
            * `invalid_query`
1633
        schema:
1634
          $ref: "../swagger.yaml#/definitions/error"
1635
      "500":
1636
        description: |
1637
          Internal server error. Possible `error_code` attribute values:
1638
1639
          * `internal_server_error`
1640
        schema:
1641
          $ref: ../swagger.yaml#/definitions/error
1642
      "503":
1643
        description: Under maintenance
1644
        schema:
1645
          $ref: ../swagger.yaml#/definitions/error
1646
    x-koha-authorization:
1647
      permissions:
1648
        parameters: manage_identity_providers
1649
"/auth/hostnames/{hostname_id}":
1650
  get:
1651
    x-mojo-to: Auth::Hostnames#get
1652
    operationId: getHostname
1653
    tags:
1654
      - identity_providers
1655
    summary: Get a hostname
1656
    parameters:
1657
      - $ref: ../swagger.yaml#/parameters/hostname_id_pp
1658
    produces:
1659
      - application/json
1660
    responses:
1661
      "200":
1662
        description: A hostname
1663
        schema:
1664
          $ref: ../swagger.yaml#/definitions/hostname
1665
      "400":
1666
        description: Bad request
1667
        schema:
1668
          $ref: "../swagger.yaml#/definitions/error"
1669
      "404":
1670
        description: Object not found
1671
        schema:
1672
          $ref: ../swagger.yaml#/definitions/error
1673
      "500":
1674
        description: |
1675
          Internal server error. Possible `error_code` attribute values:
1676
1677
          * `internal_server_error`
1678
        schema:
1679
          $ref: ../swagger.yaml#/definitions/error
1680
      "503":
1681
        description: Under maintenance
1682
        schema:
1683
          $ref: ../swagger.yaml#/definitions/error
1684
    x-koha-authorization:
1685
      permissions:
1686
        parameters: manage_identity_providers
(-)a/api/v1/swagger/swagger.yaml (-1 / +36 lines)
Lines 20-25 definitions: Link Here
20
    $ref: ./definitions/identity_provider.yaml
20
    $ref: ./definitions/identity_provider.yaml
21
  identity_provider_domain:
21
  identity_provider_domain:
22
    $ref: ./definitions/identity_provider_domain.yaml
22
    $ref: ./definitions/identity_provider_domain.yaml
23
  identity_provider_mapping:
24
    $ref: ./definitions/identity_provider_mapping.yaml
25
  hostname:
26
    $ref: ./definitions/hostname.yaml
27
  identity_provider_hostname:
28
    $ref: ./definitions/identity_provider_hostname.yaml
23
  basket:
29
  basket:
24
    $ref: ./definitions/basket.yaml
30
    $ref: ./definitions/basket.yaml
25
  booking:
31
  booking:
Lines 269-274 paths: Link Here
269
    $ref: ./paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains
275
    $ref: ./paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains
270
  "/auth/identity_providers/{identity_provider_id}/domains/{identity_provider_domain_id}":
276
  "/auth/identity_providers/{identity_provider_id}/domains/{identity_provider_domain_id}":
271
    $ref: ./paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains~1{identity_provider_domain_id}
277
    $ref: ./paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1domains~1{identity_provider_domain_id}
278
  "/auth/identity_providers/{identity_provider_id}/mappings":
279
    $ref: ./paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1mappings
280
  "/auth/identity_providers/{identity_provider_id}/mappings/{identity_provider_mapping_id}":
281
    $ref: "./paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1mappings~1{identity_provider_mapping_id}"
282
  /auth/hostnames:
283
    $ref: ./paths/auth.yaml#/~1auth~1hostnames
284
  "/auth/hostnames/{hostname_id}":
285
    $ref: "./paths/auth.yaml#/~1auth~1hostnames~1{hostname_id}"
286
  "/auth/identity_providers/{identity_provider_id}/hostnames":
287
    $ref: "./paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1hostnames"
288
  "/auth/identity_providers/{identity_provider_id}/hostnames/{identity_provider_hostname_id}":
289
    $ref: "./paths/auth.yaml#/~1auth~1identity_providers~1{identity_provider_id}~1hostnames~1{identity_provider_hostname_id}"
272
  /authorised_value_categories:
290
  /authorised_value_categories:
273
    $ref: ./paths/authorised_value_categories.yaml#/~1authorised_value_categories
291
    $ref: ./paths/authorised_value_categories.yaml#/~1authorised_value_categories
274
  "/authorised_value_categories/{authorised_value_category_name}/authorised_values":
292
  "/authorised_value_categories/{authorised_value_category_name}/authorised_values":
Lines 711-716 parameters: Link Here
711
    name: identity_provider_domain_id
729
    name: identity_provider_domain_id
712
    required: true
730
    required: true
713
    type: integer
731
    type: integer
732
  identity_provider_mapping_id_pp:
733
    description: Identity provider field mapping internal identifier
734
    in: path
735
    name: identity_provider_mapping_id
736
    required: true
737
    type: integer
738
  hostname_id_pp:
739
    description: Hostname internal identifier
740
    in: path
741
    name: hostname_id
742
    required: true
743
    type: integer
744
  identity_provider_hostname_id_pp:
745
    description: Identity provider hostname internal identifier
746
    in: path
747
    name: identity_provider_hostname_id
748
    required: true
749
    type: integer
714
  biblio_id_pp:
750
  biblio_id_pp:
715
    description: Record internal identifier
751
    description: Record internal identifier
716
    in: path
752
    in: path
717
- 

Return to bug 39224