From 2dc116fc3c41c2bce29c8c9229f6e5178282d9c5 Mon Sep 17 00:00:00 2001 From: Martin Renvoize Date: Wed, 11 Mar 2026 10:05:29 +0000 Subject: [PATCH] Bug 40596: Add Koha::Auth::Identity::Provider::CAS class Adds a new CAS protocol class to the identity provider framework. CAS providers store their connection details in the config JSON blob: server_url (required) - base URL of the CAS server version (optional) - '2' (default) or '3' Updates Koha::Auth::Identity::Providers to include CAS in the polymorphic protocol map alongside OAuth, OIDC, and SAML2. --- Koha/Auth/Identity/Provider/CAS.pm | 58 ++++++++++++++++++++++++++++++ Koha/Auth/Identity/Providers.pm | 2 ++ 2 files changed, 60 insertions(+) create mode 100644 Koha/Auth/Identity/Provider/CAS.pm diff --git a/Koha/Auth/Identity/Provider/CAS.pm b/Koha/Auth/Identity/Provider/CAS.pm new file mode 100644 index 00000000000..2b9bfb3651d --- /dev/null +++ b/Koha/Auth/Identity/Provider/CAS.pm @@ -0,0 +1,58 @@ +package Koha::Auth::Identity::Provider::CAS; + +# 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::CAS - CAS identity provider class + +=head1 API + +=head2 Class methods + +=head3 new + + my $cas = Koha::Auth::Identity::Provider::CAS->new( \%{params} ); + +Overloaded constructor that sets protocol to 'CAS'. + +=cut + +sub new { + my ( $class, $params ) = @_; + + $params->{protocol} = 'CAS'; + + return $class->SUPER::new($params); +} + +=head2 Internal methods + +=head3 mandatory_config_attributes + +Returns a list of the mandatory config entries for the protocol. + +=cut + +sub mandatory_config_attributes { + return qw(server_url); +} + +1; diff --git a/Koha/Auth/Identity/Providers.pm b/Koha/Auth/Identity/Providers.pm index a07c8d994cd..c1e97f1f75b 100644 --- a/Koha/Auth/Identity/Providers.pm +++ b/Koha/Auth/Identity/Providers.pm @@ -21,6 +21,7 @@ use Modern::Perl; use Koha::Auth::Identity::Provider; use Koha::Auth::Identity::Provider::Hostnames; +use Koha::Auth::Identity::Provider::CAS; use Koha::Auth::Identity::Provider::OAuth; use Koha::Auth::Identity::Provider::OIDC; use Koha::Auth::Identity::Provider::SAML2; @@ -94,6 +95,7 @@ Return the mapping from protocol value to implementing class name sub _polymorphic_map { return { + CAS => 'Koha::Auth::Identity::Provider::CAS', OAuth => 'Koha::Auth::Identity::Provider::OAuth', OIDC => 'Koha::Auth::Identity::Provider::OIDC', SAML2 => 'Koha::Auth::Identity::Provider::SAML2', -- 2.53.0