diff --git a/auth/cas/CAS/readme_moodle.txt b/auth/cas/CAS/readme_moodle.txt
new file mode 100644
index 00000000000..40408648c06
--- /dev/null
+++ b/auth/cas/CAS/readme_moodle.txt
@@ -0,0 +1,24 @@
+Description of phpCAS 1.4.0 import into Moodle
+
+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
diff --git a/auth/cas/auth.php b/auth/cas/auth.php
index c29c9205e81..33b303a0349 100644
--- a/auth/cas/auth.php
+++ b/auth/cas/auth.php
@@ -29,7 +29,8 @@
defined('MOODLE_INTERNAL') || die();
require_once($CFG->dirroot.'/auth/ldap/auth.php');
-require_once($CFG->dirroot.'/auth/cas/CAS/CAS.php');
+require_once($CFG->dirroot.'/auth/cas/CAS/vendor/autoload.php');
+require_once($CFG->dirroot.'/auth/cas/CAS/vendor/apereo/phpcas/source/CAS.php');
/**
* CAS authentication plugin.
diff --git a/auth/cas/thirdpartylibs.xml b/auth/cas/thirdpartylibs.xml
index 2316d3914ac..8a0579cd424 100644
--- a/auth/cas/thirdpartylibs.xml
+++ b/auth/cas/thirdpartylibs.xml
@@ -4,7 +4,7 @@
CAS
CAS
Apache
- 1.3.8
+ 1.4.0
2.0