From a957ad554b3424846fdb3e647d47af0a2e7251f1 Mon Sep 17 00:00:00 2001 From: Jacob O'Mara Date: Sun, 22 Feb 2026 20:17:33 +0000 Subject: [PATCH] Bug 39224: DBIx::Class schema update Auto-generated DBIx::Class schema updates from database changes: - New Result classes: Hostname, IdentityProviderHostname, IdentityProviderMapping - Updated Result classes: IdentityProvider (new columns and relationships), IdentityProviderDomain (new relationships) Sponsored-by: ByWater Solutions --- Koha/Schema/Result/Hostname.pm | 98 +++++++++++ Koha/Schema/Result/IdentityProvider.pm | 63 +++++--- Koha/Schema/Result/IdentityProviderDomain.pm | 14 +- .../Schema/Result/IdentityProviderHostname.pm | 152 ++++++++++++++++++ Koha/Schema/Result/IdentityProviderMapping.pm | 140 ++++++++++++++++ 5 files changed, 442 insertions(+), 25 deletions(-) create mode 100644 Koha/Schema/Result/Hostname.pm create mode 100644 Koha/Schema/Result/IdentityProviderHostname.pm create mode 100644 Koha/Schema/Result/IdentityProviderMapping.pm diff --git a/Koha/Schema/Result/Hostname.pm b/Koha/Schema/Result/Hostname.pm new file mode 100644 index 00000000000..660973c8848 --- /dev/null +++ b/Koha/Schema/Result/Hostname.pm @@ -0,0 +1,98 @@ +use utf8; +package Koha::Schema::Result::Hostname; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::Hostname - Canonical hostname registry for identity provider selection + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("hostnames"); + +=head1 ACCESSORS + +=head2 hostname_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +Unique identifier for this hostname + +=head2 hostname + + data_type: 'varchar' + is_nullable: 0 + size: 255 + +Server hostname string + +=cut + +__PACKAGE__->add_columns( + "hostname_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "hostname", + { data_type => "varchar", is_nullable => 0, size => 255 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("hostname_id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("hostname", ["hostname"]); + +=head1 RELATIONS + +=head2 identity_provider_hostnames + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "identity_provider_hostnames", + "Koha::Schema::Result::IdentityProviderHostname", + { "foreign.hostname_id" => "self.hostname_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2026-02-20 10:20:26 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:uvzH69NxZ1akNcfsvgRDIg + +1; diff --git a/Koha/Schema/Result/IdentityProvider.pm b/Koha/Schema/Result/IdentityProvider.pm index ac9c02edaab..5c05f3d9cea 100644 --- a/Koha/Schema/Result/IdentityProvider.pm +++ b/Koha/Schema/Result/IdentityProvider.pm @@ -50,7 +50,7 @@ Description for the provider =head2 protocol data_type: 'enum' - extra: {list => ["OAuth","OIDC","LDAP","CAS"]} + extra: {list => ["OAuth","OIDC","SAML2"]} is_nullable: 0 Protocol provider speaks @@ -62,20 +62,13 @@ Protocol provider speaks Configuration of the provider in JSON format -=head2 mapping +=head2 enabled - data_type: 'longtext' + data_type: 'tinyint' + default_value: 1 is_nullable: 0 -Configuration to map provider data to Koha user - -=head2 matchpoint - - data_type: 'enum' - extra: {list => ["email","userid","cardnumber"]} - is_nullable: 0 - -The patron attribute to be used as matchpoint +Whether this provider is active =head2 icon_url @@ -97,19 +90,13 @@ __PACKAGE__->add_columns( "protocol", { data_type => "enum", - extra => { list => ["OAuth", "OIDC", "LDAP", "CAS"] }, + extra => { list => ["OAuth", "OIDC", "SAML2"] }, is_nullable => 0, }, "config", { data_type => "longtext", is_nullable => 0 }, - "mapping", - { data_type => "longtext", is_nullable => 0 }, - "matchpoint", - { - data_type => "enum", - extra => { list => ["email", "userid", "cardnumber"] }, - is_nullable => 0, - }, + "enabled", + { data_type => "tinyint", default_value => 1, is_nullable => 0 }, "icon_url", { data_type => "varchar", is_nullable => 1, size => 255 }, ); @@ -157,9 +144,39 @@ __PACKAGE__->has_many( { cascade_copy => 0, cascade_delete => 0 }, ); +=head2 identity_provider_hostnames + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "identity_provider_hostnames", + "Koha::Schema::Result::IdentityProviderHostname", + { "foreign.identity_provider_id" => "self.identity_provider_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + +=head2 identity_provider_mappings + +Type: has_many + +Related object: L + +=cut + +__PACKAGE__->has_many( + "identity_provider_mappings", + "Koha::Schema::Result::IdentityProviderMapping", + { "foreign.identity_provider_id" => "self.identity_provider_id" }, + { cascade_copy => 0, cascade_delete => 0 }, +); + -# Created by DBIx::Class::Schema::Loader v0.07049 @ 2022-11-10 13:01:32 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:xSD/bRC3hJCF+nP/EYwn3Q +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2026-02-21 07:16:46 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:4T1F2ggwQdvVV7jskMZwig __PACKAGE__->has_many( "domains", diff --git a/Koha/Schema/Result/IdentityProviderDomain.pm b/Koha/Schema/Result/IdentityProviderDomain.pm index 341d1a67090..9a0af083e8c 100644 --- a/Koha/Schema/Result/IdentityProviderDomain.pm +++ b/Koha/Schema/Result/IdentityProviderDomain.pm @@ -105,6 +105,14 @@ Allow user auto register (OPAC) Allow user auto register (Staff interface) +=head2 send_welcome_email + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + +Send welcome email to patron on first login + =cut __PACKAGE__->add_columns( @@ -128,6 +136,8 @@ __PACKAGE__->add_columns( { data_type => "tinyint", default_value => 0, is_nullable => 0 }, "auto_register_staff", { data_type => "tinyint", default_value => 0, is_nullable => 0 }, + "send_welcome_email", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, ); =head1 PRIMARY KEY @@ -216,8 +226,8 @@ __PACKAGE__->belongs_to( ); -# Created by DBIx::Class::Schema::Loader v0.07051 @ 2024-08-22 18:15:05 -# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:GpRUQgJ3WUt9nAAS0E9qWw +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2026-02-21 07:16:46 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:7M7qCu+9WGNjvvaqxyL6Aw __PACKAGE__->add_columns( '+auto_register_opac' => { is_boolean => 1 }, diff --git a/Koha/Schema/Result/IdentityProviderHostname.pm b/Koha/Schema/Result/IdentityProviderHostname.pm new file mode 100644 index 00000000000..fe2f121e12a --- /dev/null +++ b/Koha/Schema/Result/IdentityProviderHostname.pm @@ -0,0 +1,152 @@ +use utf8; +package Koha::Schema::Result::IdentityProviderHostname; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::IdentityProviderHostname + +=head1 DESCRIPTION + +Maps server hostnames to identity providers (many-to-many). A hostname may be linked to multiple providers. + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("identity_provider_hostnames"); + +=head1 ACCESSORS + +=head2 identity_provider_hostname_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +unique key, used to identify the hostname entry + +=head2 hostname_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +FK to hostnames table + +=head2 identity_provider_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +Identity provider associated with this hostname + +=head2 is_enabled + + data_type: 'tinyint' + default_value: 1 + is_nullable: 0 + +Whether this hostname is active for this provider + +=head2 force_sso + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + +Force SSO redirect for users on this hostname + +=cut + +__PACKAGE__->add_columns( + "identity_provider_hostname_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "hostname_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "identity_provider_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "is_enabled", + { data_type => "tinyint", default_value => 1, is_nullable => 0 }, + "force_sso", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("identity_provider_hostname_id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint( + "hostname_id_provider", + ["hostname_id", "identity_provider_id"], +); + +=head1 RELATIONS + +=head2 hostname + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "hostname", + "Koha::Schema::Result::Hostname", + { hostname_id => "hostname_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, +); + +=head2 identity_provider + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "identity_provider", + "Koha::Schema::Result::IdentityProvider", + { identity_provider_id => "identity_provider_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2026-02-21 07:16:46 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:K31ZTdC8ZmSuuKPACLnrUQ + +1; diff --git a/Koha/Schema/Result/IdentityProviderMapping.pm b/Koha/Schema/Result/IdentityProviderMapping.pm new file mode 100644 index 00000000000..eb52b4bbc7f --- /dev/null +++ b/Koha/Schema/Result/IdentityProviderMapping.pm @@ -0,0 +1,140 @@ +use utf8; +package Koha::Schema::Result::IdentityProviderMapping; + +# Created by DBIx::Class::Schema::Loader +# DO NOT MODIFY THE FIRST PART OF THIS FILE + +=head1 NAME + +Koha::Schema::Result::IdentityProviderMapping + +=cut + +use strict; +use warnings; + +use base 'DBIx::Class::Core'; + +=head1 TABLE: C + +=cut + +__PACKAGE__->table("identity_provider_mappings"); + +=head1 ACCESSORS + +=head2 mapping_id + + data_type: 'integer' + is_auto_increment: 1 + is_nullable: 0 + +primary key + +=head2 identity_provider_id + + data_type: 'integer' + is_foreign_key: 1 + is_nullable: 0 + +Reference to identity provider + +=head2 provider_field + + data_type: 'varchar' + is_nullable: 1 + size: 255 + +Attribute name from the identity provider + +=head2 koha_field + + data_type: 'varchar' + is_nullable: 0 + size: 255 + +Corresponding field in Koha borrowers table + +=head2 default_content + + data_type: 'varchar' + is_nullable: 1 + size: 255 + +Default value if provider does not supply this field + +=head2 is_matchpoint + + data_type: 'tinyint' + default_value: 0 + is_nullable: 0 + +Use this field to match existing patrons + +=cut + +__PACKAGE__->add_columns( + "mapping_id", + { data_type => "integer", is_auto_increment => 1, is_nullable => 0 }, + "identity_provider_id", + { data_type => "integer", is_foreign_key => 1, is_nullable => 0 }, + "provider_field", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "koha_field", + { data_type => "varchar", is_nullable => 0, size => 255 }, + "default_content", + { data_type => "varchar", is_nullable => 1, size => 255 }, + "is_matchpoint", + { data_type => "tinyint", default_value => 0, is_nullable => 0 }, +); + +=head1 PRIMARY KEY + +=over 4 + +=item * L + +=back + +=cut + +__PACKAGE__->set_primary_key("mapping_id"); + +=head1 UNIQUE CONSTRAINTS + +=head2 C + +=over 4 + +=item * L + +=item * L + +=back + +=cut + +__PACKAGE__->add_unique_constraint("provider_koha_field", ["identity_provider_id", "koha_field"]); + +=head1 RELATIONS + +=head2 identity_provider + +Type: belongs_to + +Related object: L + +=cut + +__PACKAGE__->belongs_to( + "identity_provider", + "Koha::Schema::Result::IdentityProvider", + { identity_provider_id => "identity_provider_id" }, + { is_deferrable => 1, on_delete => "CASCADE", on_update => "RESTRICT" }, +); + + +# Created by DBIx::Class::Schema::Loader v0.07051 @ 2026-02-20 10:20:26 +# DO NOT MODIFY THIS OR ANYTHING ABOVE! md5sum:x2JmD4As/a96Ndoe5rzuKg + +1; -- 2.53.0