Skip to content

Commit

Permalink
Merge branch 'MDL-71713-master' of https://github.com/cescobedo/moodle
Browse files Browse the repository at this point in the history
  • Loading branch information
ilyatregubov committed Feb 9, 2022
2 parents 7d743b2 + fafa097 commit acb4791
Show file tree
Hide file tree
Showing 84 changed files with 3,435 additions and 384 deletions.
25 changes: 23 additions & 2 deletions auth/cas/CAS/readme_moodle.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
Description of phpCAS 1.3.8 library import
Description of phpCAS 1.4.0 import into Moodle

* downloaded source code from https://github.com/apereo/phpCAS/releases
Last release package can be found in hhttps://github.com/apereo/phpCAS/releases

NOTICE:
* Before running composer command, make sure you have the composer version updated.
* Composer version 2.2.4 2022-01-08 12:30:42

STEPS:
* Create a temporary folder outside your moodle installation
* Execute `composer require apereo/phpcas:VERSION`
* Check any new libraries that have been added and make sure they do not exist in Moodle already.
* Remove the old 'vendor' directory in auth/cas/CAS/
* Copy contents of 'vendor' directory
* Create a commit with only the library changes
* Update auth/cas/thirdpartylibs.xml
* Apply the modifications described in the CHANGES section
* Create another commit with the previous two steps of changes

CHANGES:
* Remove all the hidden folders and files in vendor/apereo/phpcas/ (find . -name ".*"):
- .codecov.yml
- .gitattributes
- .github
32 changes: 32 additions & 0 deletions auth/cas/CAS/vendor/apereo/phpcas/CAS.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<?php

/**
* Licensed to Jasig under one or more contributor license
* agreements. See the NOTICE file distributed with this work for
* additional information regarding copyright ownership.
*
* Jasig licenses this file to you under the Apache License,
* Version 2.0 (the "License"); you may not use this file except in
* compliance with the License. You may obtain a copy of the License at:
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
* PHP Version 5
*
* @file CAS.php
* @category Authentication
* @package PhpCAS
* @author Adam Franco <[email protected]>
* @license http://www.apache.org/licenses/LICENSE-2.0 Apache License 2.0
* @link https://wiki.jasig.org/display/CASC/phpCAS
*/

require_once __DIR__.'/source/CAS.php';

trigger_error('Including CAS.php is deprecated. Install phpCAS using composer instead.', E_USER_DEPRECATED);
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@ users via a Central Authentication Service (CAS) server.

Please see the wiki website for more information:

https://wiki.jasig.org/display/CASC/phpCAS
https://apereo.github.io/phpCAS/

Api documentation can be found here:

https://apereo.github.io/phpCAS/
https://apereo.github.io/phpCAS/api/


[![Build Status](https://travis-ci.org/apereo/phpCAS.png)](https://travis-ci.org/apereo/phpCAS)


LICENSE
-------

Copyright 2007-2015, JA-SIG, Inc.
This project includes software developed by Jasig.
http://www.jasig.org/
Copyright 2007-2020, Apereo Foundation.
This project includes software developed by Apereo Foundation.
http://www.apereo.org/

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this software except in compliance with the License.
Expand Down
51 changes: 51 additions & 0 deletions auth/cas/CAS/vendor/apereo/phpcas/composer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
{
"name" : "apereo/phpcas",
"description" : "Provides a simple API for authenticating users against a CAS server",
"keywords" : [
"cas",
"jasig",
"apereo"
],
"homepage" : "https://wiki.jasig.org/display/CASC/phpCAS",
"type" : "library",
"license" : "Apache-2.0",
"authors" : [{
"name" : "Joachim Fritschi",
"homepage" : "https://github.com/jfritschi",
"email" : "[email protected]"
}, {
"name" : "Adam Franco",
"homepage" : "https://github.com/adamfranco"
}, {
"name" : "Henry Pan",
"homepage" : "https://github.com/phy25"
}
],
"require" : {
"php" : ">=7.0.0",
"ext-curl" : "*",
"psr/log" : "^1.0.0"
},
"require-dev" : {
"monolog/monolog" : "^1.0.0",
"phpunit/phpunit" : ">=4.8.35 <8"
},
"autoload" : {
"classmap" : [
"source/"
]
},
"autoload-dev" : {
"psr-4" : {
"PhpCas\\" : "test/CAS/"
}
},
"scripts" : {
"test" : "phpunit"
},
"extra" : {
"branch-alias" : {
"dev-master" : "1.3.x-dev"
}
}
}
21 changes: 21 additions & 0 deletions auth/cas/CAS/vendor/apereo/phpcas/phpunit.xml.dist
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
<?xml version="1.0" encoding="UTF-8"?>
<phpunit
bootstrap="source/CAS.php"
convertNoticesToExceptions="false"
colors="true"
stderr="true"
backupGlobals="true"
>

<testsuites>
<testsuite name="phpCAS Tests">
<directory>test/CAS/Tests/</directory>
</testsuite>
</testsuites>

<filter>
<whitelist addUncoveredFilesFromWhitelist="false">
<directory>source/</directory>
</whitelist>
</filter>
</phpunit>
102 changes: 70 additions & 32 deletions auth/cas/CAS/CAS.php → ...s/CAS/vendor/apereo/phpcas/source/CAS.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@
* @ingroup public
*/

use Psr\Log\LoggerInterface;

//
// hack by Vangelis Haniotakis to handle the absence of $_SERVER['REQUEST_URI']
Expand All @@ -44,11 +45,6 @@
$_SERVER['REQUEST_URI'] = $_SERVER['SCRIPT_NAME'] . '?' . $_SERVER['QUERY_STRING'];
}

// Add a E_USER_DEPRECATED for php versions <= 5.2
if (!defined('E_USER_DEPRECATED')) {
define('E_USER_DEPRECATED', E_USER_NOTICE);
}


// ########################################################################
// CONSTANTS
Expand All @@ -61,7 +57,7 @@
/**
* phpCAS version. accessible for the user by phpCAS::getVersion().
*/
define('PHPCAS_VERSION', '1.3.8');
define('PHPCAS_VERSION', '1.4.0');

/**
* @addtogroup public
Expand Down Expand Up @@ -224,6 +220,8 @@
define("PHPCAS_LANG_SPANISH", 'CAS_Languages_Spanish');
define("PHPCAS_LANG_CATALAN", 'CAS_Languages_Catalan');
define("PHPCAS_LANG_CHINESE_SIMPLIFIED", 'CAS_Languages_ChineseSimplified');
define("PHPCAS_LANG_GALEGO", 'CAS_Languages_Galego');
define("PHPCAS_LANG_PORTUGUESE", 'CAS_Languages_Portuguese');

/** @} */

Expand Down Expand Up @@ -261,7 +259,7 @@ function gettmpdir() {
/** @} */

// include the class autoloader
require_once dirname(__FILE__) . '/CAS/Autoload.php';
require_once __DIR__ . '/CAS/Autoload.php';

/**
* The phpCAS class is a simple container for the phpCAS library. It provides CAS
Expand Down Expand Up @@ -330,20 +328,22 @@ class phpCAS
/**
* phpCAS client initializer.
*
* @param string $server_version the version of the CAS server
* @param string $server_hostname the hostname of the CAS server
* @param int $server_port the port the CAS server is running on
* @param string $server_uri the URI the CAS server is responding on
* @param bool $changeSessionID Allow phpCAS to change the session_id (Single
* Sign Out/handleLogoutRequests is based on that change)
* @param string $server_version the version of the CAS server
* @param string $server_hostname the hostname of the CAS server
* @param int $server_port the port the CAS server is running on
* @param string $server_uri the URI the CAS server is responding on
* @param bool $changeSessionID Allow phpCAS to change the session_id
* (Single Sign Out/handleLogoutRequests
* is based on that change)
* @param \SessionHandlerInterface $sessionHandler the session handler
*
* @return void a newly created CAS_Client object
* @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
* called, only once, and before all other methods (except phpCAS::getVersion()
* and phpCAS::setDebug()).
*/
public static function client($server_version, $server_hostname,
$server_port, $server_uri, $changeSessionID = true
$server_port, $server_uri, $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null
) {
phpCAS :: traceBegin();
if (is_object(self::$_PHPCAS_CLIENT)) {
Expand All @@ -363,7 +363,7 @@ public static function client($server_version, $server_hostname,
try {
self::$_PHPCAS_CLIENT = new CAS_Client(
$server_version, false, $server_hostname, $server_port, $server_uri,
$changeSessionID
$changeSessionID, $sessionHandler
);
} catch (Exception $e) {
phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
Expand All @@ -374,20 +374,22 @@ public static function client($server_version, $server_hostname,
/**
* phpCAS proxy initializer.
*
* @param string $server_version the version of the CAS server
* @param string $server_hostname the hostname of the CAS server
* @param int $server_port the port the CAS server is running on
* @param string $server_uri the URI the CAS server is responding on
* @param bool $changeSessionID Allow phpCAS to change the session_id (Single
* Sign Out/handleLogoutRequests is based on that change)
* @param string $server_version the version of the CAS server
* @param string $server_hostname the hostname of the CAS server
* @param string $server_port the port the CAS server is running on
* @param string $server_uri the URI the CAS server is responding on
* @param bool $changeSessionID Allow phpCAS to change the session_id
* (Single Sign Out/handleLogoutRequests
* is based on that change)
* @param \SessionHandlerInterface $sessionHandler the session handler
*
* @return void a newly created CAS_Client object
* @note Only one of the phpCAS::client() and phpCAS::proxy functions should be
* called, only once, and before all other methods (except phpCAS::getVersion()
* and phpCAS::setDebug()).
*/
public static function proxy($server_version, $server_hostname,
$server_port, $server_uri, $changeSessionID = true
$server_port, $server_uri, $changeSessionID = true, \SessionHandlerInterface $sessionHandler = null
) {
phpCAS :: traceBegin();
if (is_object(self::$_PHPCAS_CLIENT)) {
Expand All @@ -407,7 +409,7 @@ public static function proxy($server_version, $server_hostname,
try {
self::$_PHPCAS_CLIENT = new CAS_Client(
$server_version, true, $server_hostname, $server_port, $server_uri,
$changeSessionID
$changeSessionID, $sessionHandler
);
} catch (Exception $e) {
phpCAS :: error(get_class($e) . ': ' . $e->getMessage());
Expand Down Expand Up @@ -435,16 +437,38 @@ public static function isInitialized ()
* @{
*/

/**
* Set/unset PSR-3 logger
*
* @param LoggerInterface $logger the PSR-3 logger used for logging, or
* null to stop logging.
*
* @return void
*/
public static function setLogger($logger = null)
{
if (empty(self::$_PHPCAS_DEBUG['unique_id'])) {
self::$_PHPCAS_DEBUG['unique_id'] = substr(strtoupper(md5(uniqid(''))), 0, 4);
}
self::$_PHPCAS_DEBUG['logger'] = $logger;
self::$_PHPCAS_DEBUG['indent'] = 0;
phpCAS :: trace('START ('.date("Y-m-d H:i:s").') phpCAS-' . PHPCAS_VERSION . ' ******************');
}

/**
* Set/unset debug mode
*
* @param string $filename the name of the file used for logging, or false
* to stop debugging.
*
* @return void
*
* @deprecated
*/
public static function setDebug($filename = '')
{
trigger_error('phpCAS::setDebug() is deprecated in favor of phpCAS::setLogger().', E_USER_DEPRECATED);

if ($filename != false && gettype($filename) != 'string') {
phpCAS :: error('type mismatched for parameter $dbg (should be false or the name of the log file)');
}
Expand Down Expand Up @@ -518,22 +542,28 @@ public static function log($str)
$indent_str = ".";


if (!empty(self::$_PHPCAS_DEBUG['filename'])) {
// Check if file exists and modifiy file permissions to be only
// readable by the webserver
if (!file_exists(self::$_PHPCAS_DEBUG['filename'])) {
touch(self::$_PHPCAS_DEBUG['filename']);
// Chmod will fail on windows
@chmod(self::$_PHPCAS_DEBUG['filename'], 0600);
}
if (isset(self::$_PHPCAS_DEBUG['logger']) || !empty(self::$_PHPCAS_DEBUG['filename'])) {
for ($i = 0; $i < self::$_PHPCAS_DEBUG['indent']; $i++) {

$indent_str .= '| ';
}
// allow for multiline output with proper identing. Usefull for
// dumping cas answers etc.
$str2 = str_replace("\n", "\n" . self::$_PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str, $str);
error_log(self::$_PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str2 . "\n", 3, self::$_PHPCAS_DEBUG['filename']);
$str3 = self::$_PHPCAS_DEBUG['unique_id'] . ' ' . $indent_str . $str2;
if (isset(self::$_PHPCAS_DEBUG['logger'])) {
self::$_PHPCAS_DEBUG['logger']->info($str3);
}
if (!empty(self::$_PHPCAS_DEBUG['filename'])) {
// Check if file exists and modifiy file permissions to be only
// readable by the webserver
if (!file_exists(self::$_PHPCAS_DEBUG['filename'])) {
touch(self::$_PHPCAS_DEBUG['filename']);
// Chmod will fail on windows
@chmod(self::$_PHPCAS_DEBUG['filename'], 0600);
}
error_log($str3 . "\n", 3, self::$_PHPCAS_DEBUG['filename']);
}
}

}
Expand Down Expand Up @@ -1869,6 +1899,14 @@ private static function _validateProxyExists()
}
}

/**
* @return CAS_Client
*/
public static function getCasClient()
{
return self::$_PHPCAS_CLIENT;
}

/**
* For testing purposes, use this method to set the client to a test double
*
Expand Down
Loading

0 comments on commit acb4791

Please sign in to comment.