From 0acf6214150da661737eaf65d2ad9e33aa337d68 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Sun, 22 Feb 2026 20:18:58 +0000 Subject: [PATCH] Bug 39224: Add SAML2 as a supported identity provider protocol Adds SAML2 support to the identity provider framework: - New Koha::Auth::Identity::Provider::SAML2 class implementing SAML2-specific configuration and behaviour - Registers SAML2 in the polymorphic protocol map in Koha::Auth::Identity::Providers This extends the existing OAuth/OIDC provider framework to also handle SAML2 identity providers through the same unified interface. Test plan: 1. Create a SAML2 identity provider Sponsored-by: ByWater Solutions --- Koha/Auth/Identity/Provider/SAML2.pm | 60 ++++++++++++++++++++++++++++ Koha/Auth/Identity/Providers.pm | 2 + 2 files changed, 62 insertions(+) create mode 100644 Koha/Auth/Identity/Provider/SAML2.pm diff --git a/Koha/Auth/Identity/Provider/SAML2.pm b/Koha/Auth/Identity/Provider/SAML2.pm new file mode 100644 index 00000000000..960f57c193e --- /dev/null +++ b/Koha/Auth/Identity/Provider/SAML2.pm @@ -0,0 +1,60 @@ +package Koha::Auth::Identity::Provider::SAML2; + +# 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 . + +use Modern::Perl; + +use base qw(Koha::Auth::Identity::Provider); + +=head1 NAME + +Koha::Auth::Identity::Provider::SAML2 - SAML2/Shibboleth identity provider class + +=head1 API + +=head2 Class methods + +=head3 new + + my $saml2 = Koha::Auth::Identity::Provider::SAML2->new( \%{params} ); + +Overloaded constructor that sets protocol to 'SAML2'. + +=cut + +sub new { + my ( $class, $params ) = @_; + + $params->{protocol} = 'SAML2'; + + return $class->SUPER::new($params); +} + +=head2 Internal methods + +=head3 mandatory_config_attributes + +SAML2 providers are configured at the web-server level (e.g. mod_shib). +Koha stores optional behavioural settings in C (autocreate, sync, welcome) +but none are mandatory. + +=cut + +sub mandatory_config_attributes { + return (); +} + +1; diff --git a/Koha/Auth/Identity/Providers.pm b/Koha/Auth/Identity/Providers.pm index 1cd47471d5b..a07c8d994cd 100644 --- a/Koha/Auth/Identity/Providers.pm +++ b/Koha/Auth/Identity/Providers.pm @@ -23,6 +23,7 @@ use Koha::Auth::Identity::Provider; use Koha::Auth::Identity::Provider::Hostnames; use Koha::Auth::Identity::Provider::OAuth; use Koha::Auth::Identity::Provider::OIDC; +use Koha::Auth::Identity::Provider::SAML2; use base qw(Koha::Objects); @@ -95,6 +96,7 @@ sub _polymorphic_map { return { OAuth => 'Koha::Auth::Identity::Provider::OAuth', OIDC => 'Koha::Auth::Identity::Provider::OIDC', + SAML2 => 'Koha::Auth::Identity::Provider::SAML2', }; } -- 2.53.0