Problem/Motivation
When I applied the Drupal 10.6.1 update to my sites, the composer dependency for doctrine/annotations was removed and many of the dependent simplesamlphp packages were downgraded.
- Removing doctrine/annotations (1.14.4)
[...]
- Upgrading drupal/core (10.5.8 => 10.6.1)
- Upgrading drupal/core-recommended (10.5.8 => 10.6.1)
- Downgrading simplesamlphp/xml-common (v1.25.1 => v1.23.2)
- Downgrading simplesamlphp/xml-security (v1.13.8 => v1.12.0)
- Downgrading simplesamlphp/simplesamlphp-assets-base (v2.4.3 => v2.3.12)
- Downgrading simplesamlphp/xml-soap (v1.7.1 => v1.6.0)
- Downgrading simplesamlphp/saml2 (v5.0.5 => v5.0.1)
- Downgrading simplesamlphp/simplesamlphp (v2.4.4 => v2.4.2)
After this update, any time I tried to log into one of my sites using the SSO authentication I received the following exception.
SimpleSAML\Error\Error: UNHANDLEDEXCEPTION
Backtrace:
2 src/SimpleSAML/Error/ExceptionHandler.php:39 (SimpleSAML\Error\ExceptionHandler::customExceptionHandler)
1 /htdocs/Drupal/vendor/symfony/error-handler/ErrorHandler.php:538 (Symfony\Component\ErrorHandler\ErrorHandler::handleException)
0 [builtin] (N/A)
Caused by: Symfony\Component\ErrorHandler\Error\ClassNotFoundError: Attempted to load class "PsrCachedReader" from namespace "Doctrine\Common\Annotations".
Did you forget a "use" statement for another namespace?
Backtrace:
12 /var/cache/simplesamlphp/saml/ContainerCxxqXww/getAnnotations_CachedReaderService.php:25 (ContainerCxxqXww\getAnnotations_CachedReaderService::do)
11 /var/cache/simplesamlphp/saml/ContainerCxxqXww/SimpleSAML_KernelProdContainer.php:95 (ContainerCxxqXww\SimpleSAML_KernelProdContainer::load)
10 /var/cache/simplesamlphp/saml/ContainerCxxqXww/SimpleSAML_KernelProdContainer.php:172 (ContainerCxxqXww\SimpleSAML_KernelProdContainer::getRouting_LoaderService)
9 /var/cache/simplesamlphp/saml/ContainerCxxqXww/SimpleSAML_KernelProdContainer.php:159 (ContainerCxxqXww\SimpleSAML_KernelProdContainer::getRouterService)
8 /var/cache/simplesamlphp/saml/ContainerCxxqXww/SimpleSAML_KernelProdContainer.php:291 (ContainerCxxqXww\SimpleSAML_KernelProdContainer::getRouterListenerService)
7 /var/cache/simplesamlphp/saml/ContainerCxxqXww/getHttpKernelService.php:22 (ContainerCxxqXww\getHttpKernelService::do)
6 /var/cache/simplesamlphp/saml/ContainerCxxqXww/SimpleSAML_KernelProdContainer.php:95 (ContainerCxxqXww\SimpleSAML_KernelProdContainer::load)
5 /htdocs/Drupal/vendor/symfony/dependency-injection/Container.php:229 (Symfony\Component\DependencyInjection\Container::make)
4 /htdocs/Drupal/vendor/symfony/dependency-injection/Container.php:211 (Symfony\Component\DependencyInjection\Container::get)
3 /htdocs/Drupal/vendor/symfony/http-kernel/Kernel.php:208 (Symfony\Component\HttpKernel\Kernel::getHttpKernel)
2 /htdocs/Drupal/vendor/symfony/http-kernel/Kernel.php:197 (Symfony\Component\HttpKernel\Kernel::handle)
1 src/SimpleSAML/Module.php:234 (SimpleSAML\Module::process)
0 public/module.php:17 (N/A)
I was able to resolve the issue by re-requiring doctrine/annotations with composer and then installing the package.
composer require doctrine/annotations:^1.0
I didn't see this issue reported in the queue so I wanted to bring it up. It is an easy fix but I'm worried it might be something unique to my setup.
Steps to reproduce
Install Drupal Core 10.6.1 without the doctrine/annotations package.
Comments
Comment #2
ben25 commentedjust to let you know, its not unique to just you - i've also just experienced this
Comment #3
ben25 commentedjust seen that its been abandoned - https://packagist.org/packages/doctrine/annotations
i wonder if simplesaml will have updated itself with this in mind
Comment #4
grzesag commentedthe same problem on my site after update from Drupal 10.5.x to 10.6.2
Comment #5
jonathan_hunt commentedI ran into the same issue updating to Drupal 10.6.2 and simpleSAMLphp 2.4.4; in my case running
composer require doctrine/annotationsto get doctrine/annotations 2.0.2 worked ok.Comment #6
jayemel commentedWe are having a similar issue with 10.6.2.
It seems the module is not compatible with 10.6?
Comment #7
berdirdrupal/core-recommended is known to cause conflicts with more complex dependencies. It locks down specific minor versions that other projects conflict with. Removing that allows to install the most recent version of simplesamlphp.
There isn't much that this project can do about this.
simplesamlphp has complex dependency chains that frequently conflict with core, symfony, guzzle and others. As mentioned in the D11 issue, I strongly recommend to review if https://www.drupal.org/project/samlauth is sufficient for your requirements and switch. We did, and so did many others.
Comment #8
grzesag commentedThank you berdir I did see in many places recommendation to move to samlauth - do you have any guidlines or resources to point to about migration from simplesamlphp to samlauth module?
Comment #9
matason commentedNot sure if this will help anyone, but I experienced this issue and found that clearing the SimpleSAMLphp cache solved it.
Comment #10
berdirThere's quite a bit of discussion in #3447463: Drupal 11 compatibility on the migration to samlauth, in #27 someone created a migration module, I didn't try it.
Comment #11
sgroundwater commentedmatason 's tip saved my bacon. Clearing the /var/cache/simplesamlphp/* cleared my error. (THANKS!)
Comment #12
benjamin_dk commentedSecond that the cache clearing fix works - I had to check my simplesamlphp config file to find the cache dir (/tmp/simplesaml).
Comment #13
grzesag commentedthank you Drupal community for your work on this, thank you , @matason, @benjamin_dk for sharing your solution, I followed it and SSO authentication works again on our Drupal 10.6 instance
keep good work!
Comment #14
mingsongComment #15
mingsongYou can try the SimpleSAMLphp (Symfony) console command to clear the cache.
Find the cache folder:
Clear the cache without warmup
All those SimpleSAMLphp cached files should be cleared after that.
Comment #16
johns996 commentedIn response to #10, I did try the migration module and it simplified the process of moving all of the settings stored in SAML's config file into the samlauth configuration. For the IDP I'm using, samlauth was an easy replacement for simplesamlphp_auth. Here's the migration module: https://www.drupal.org/sandbox/jrb/3531935. Thanks @berdir!
Comment #17
justcaldwellWe're also looking to move to samlauth.
In the meantime, clearing the simplesamlphp cache partially worked in our case. We can now authenticate to Drupal, but we're still unable to log into the simplesamlphp admin application (e.g. '/simplesaml/admin')—that still throws the same exception.
Comment #18
dak5859 commentedBeen a few months since the last post here. We are running into issues using this module after upgrading to D11.3.8 due to the removal of doctrine/annotations and even when replacing that with v2.0.2 - the following error related to some sort of issue with the way the updated symfony/routing package (7.4.8) (which is required on D11) is interacting with our SAML login process. We get the following error when attempting to login and the IDP returns us to the site.
Did anyone have this same issue and find a fix? Or is the only solution to move away from simplesamlphp_auth. We were hoping to keep that solution in use for our SSO but are open to shifting to SAML Auth module if there is no workaround.
Backtrace:
2 src/SimpleSAML/Error/ExceptionHandler.php:47 (SimpleSAML\Error\ExceptionHandler::customExceptionHandler)
1 /var/www/docker_platform/vendor/symfony/error-handler/ErrorHandler.php:538 (Symfony\Component\ErrorHandler\ErrorHandler::handleException)
0 [builtin] (N/A)
Caused by: TypeError: Symfony\Component\Routing\Loader\AttributeClassLoader::__construct(): Argument #1 ($env) must be of type ?string, Doctrine\Common\Annotations\PsrCachedReader given, called in /tmp/simplesaml/saml/Container0czZbxY/SimpleSAML_KernelProdContainer.php on line 172
Backtrace:
11 /var/www/docker_platform/vendor/symfony/routing/Loader/AttributeClassLoader.php:65 (Symfony\Component\Routing\Loader\AttributeClassLoader::__construct)
10 /tmp/simplesaml/saml/Container0czZbxY/SimpleSAML_KernelProdContainer.php:172 (Container0czZbxY\SimpleSAML_KernelProdContainer::getRouting_LoaderService)
9 /tmp/simplesaml/saml/Container0czZbxY/SimpleSAML_KernelProdContainer.php:159 (Container0czZbxY\SimpleSAML_KernelProdContainer::getRouterService)
8 /tmp/simplesaml/saml/Container0czZbxY/SimpleSAML_KernelProdContainer.php:291 (Container0czZbxY\SimpleSAML_KernelProdContainer::getRouterListenerService)
7 /tmp/simplesaml/saml/Container0czZbxY/getHttpKernelService.php:22 (Container0czZbxY\getHttpKernelService::do)
6 /tmp/simplesaml/saml/Container0czZbxY/SimpleSAML_KernelProdContainer.php:95 (Container0czZbxY\SimpleSAML_KernelProdContainer::load)
5 /var/www/docker_platform/vendor/symfony/dependency-injection/Container.php:221 (Symfony\Component\DependencyInjection\Container::make)
4 /var/www/docker_platform/vendor/symfony/dependency-injection/Container.php:203 (Symfony\Component\DependencyInjection\Container::get)
3 /var/www/docker_platform/vendor/symfony/http-kernel/Kernel.php:204 (Symfony\Component\HttpKernel\Kernel::getHttpKernel)
2 /var/www/docker_platform/vendor/symfony/http-kernel/Kernel.php:193 (Symfony\Component\HttpKernel\Kernel::handle)
1 src/SimpleSAML/Module.php:240 (SimpleSAML\Module::process)
0 public/module.php:17 (N/A)
Comment #19
justcaldwellHi @dak5859. We've just updated from D10.6.7 to D11.3.9. We have required doctrine/annotations (2.0.2) until we can move to samlauth.
We're able to authenticate successfully, so no error on returning form the IDP. But, attempting to visit the local simplesamlphp admin app did yield the same error you include above. In our case, clearing the simplesaml cache as recommended in #12 resolved the issue.
Comment #20
dak5859 commentedThanks for the update @justcaldwell. As mentioned, I tried to enable doctrine/annotations 2.0.2 with that same error i posted.
How did you clear the simplesamlph cache? I couldn't find a cache dir in that /tmp/simplesaml directory and those console commands from #15 did not run properly with a "command not found" response. We're using Docker and memcache and also tried to restart memcache service but that did not appear to clear simplesamlphp cache.
Comment #21
justcaldwellThe console commands never worked for me, either.
To do it manually, check your simplesamlphp
config.phpto see if the directory is defined there; look for the 'tempdir' key. So, something like:$config['tempdir'] = '/tmp/some-directory';Then delete the contents of 'some-directory'.
Comment #22
dak5859 commentedThis is what i see in my config.php file when searching on 'tempdir'.
- 'tempdir': Saving temporary files. SimpleSAMLphp will attempt to create
* this directory if it doesn't exist.
* When specified as a relative path, this is relative to the SimpleSAMLphp
* root directory.
*/
'certdir' => 'cert/',
'loggingdir' => '/tmp',
'datadir' => 'data/',
'tempdir' => '/tmp/simplesaml',
When visiting that /tmp/simplesaml directory - i see it contains another directory called 'saml'. Are you saying I should delete that entire 'saml' directory?
That contains the following files and directories (Container0czZbxY, Symfony, pools):
-rw-r--r-- 1 root root 12288 May 6 08:44 .annotations.map.swp
drwxr-xr-x 2 www-data www-data 12288 May 5 12:35 Container0czZbxY
-rw-r--r-- 1 www-data www-data 893 Apr 17 10:25 SimpleSAML_KernelProdContainer.php
-rw-r--r-- 1 www-data www-data 0 Apr 17 10:25 SimpleSAML_KernelProdContainer.php.lock
-rw-r--r-- 1 www-data www-data 6117 Apr 17 10:25 SimpleSAML_KernelProdContainer.php.meta
-rw-r--r-- 1 www-data www-data 11240 Apr 17 10:25 SimpleSAML_KernelProdContainer.preload.php
drwxr-xr-x 3 www-data www-data 4096 Apr 17 10:25 Symfony
-rw-r--r-- 1 www-data www-data 98 Apr 17 10:25 annotations.map
drwxr-xr-x 3 www-data www-data 4096 Apr 17 10:25 pools
Comment #23
justcaldwellYes. Simplesamlphp will recreate it next time someone authenticates.
Comment #24
dak5859 commented@justcaldwell AMAZING! That worked. I was able to successfully login via our dev OKTA app. I'm guessing we could do the same in our prod environment to make sure it works as expected too.
Also, if you don't mind answering, what was the local simplesamlphp admin app you were referring too? I'm not familiar with that UI so I don't believe it would be a blocker if it's still throwing that SAML error I posted for you as mentioned before.
Comment #25
justcaldwellIf you enable it, simplesamlphp exposes a small admin app suite that provides to testing/admin tools. It's at
simplesamlphp/simplesamlphp/public.This all depends on your setup, where your vendor directory is, etc., but typically you'd have a symlink in your public web root that points to that 'public' directory so you can access it on your web server, e.g.
ln -s ../vendor/simplesamlphp/simplesamlphp/public docroot/simplesamlThen you'd access it at https://yourserver.com/simplesaml/admin.
It's handy but not essential if authentication is working properly for you. If you don't see 'core' or 'admin' directories in
/tmp/simplesaml, then it could be it was never enabled or used in your environment.Comment #26
dak5859 commentedUnderstood. Looks I do have access to that UI via the path you mentioned in my test QA environment. Only see a SAML error when after I login and then go to "Federation" page. I don't think we'll need to play around in there anyway though. Thanks again for all of your help! Saved me a lot of time and lets us take our time with the transition to SAML AUTH module.
Comment #27
dak5859 commented@justcaldwell fysa - i was doing some more testing and I ended up removing that doctrine/annotations (2.0.2) package from my lock file and the SAML login still worked in my test environment. So it appears that original error might have been directly caused by that stale simplesamlphp cache. Doesn't appear that doctrine/annotations package is needed after all (as that does get removed during the D10 to D11 upgrade)
Comment #28
justcaldwellGlad to help!
One last note: in the process of working through our upgrade to D11, I've realized that as long as the simplesamlphp cache is fully deleted,
doctrine/annotationsisn't needed to resolve this issue (for us at least). So we've removed it.My mistake in #17 was that I only deleted the 'saml' cache directory, but left others.