Problem/Motivation
I have a site running Drupal 10.1.7. When I install and enable the module, a number of site functions break down. For example, when existing users (not created by SAML) attempt to login, they experience the error:
The website encountered an unexpected error. Please try again later.
Drupal\Core\Database\DatabaseExceptionWrapper: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cab.authmap' doesn't exist: SELECT "am"."authname" AS "authname" FROM "authmap" "am" WHERE ("uid" = :db_condition_placeholder_0) AND ("provider" = :db_condition_placeholder_1) LIMIT 1 OFFSET 0; Array ( [:db_condition_placeholder_0] => 2 [:db_condition_placeholder_1] => samlauth ) in Drupal\externalauth\Authmap->get() (line 63 of modules/contrib/externalauth/src/Authmap.php).
Drupal\Core\Database\StatementWrapperIterator->execute(Array, Array) (Line: 790)
Drupal\Core\Database\Connection->query('SELECT "am"."authname" AS "authname"
FROM
{authmap} "am"
WHERE ("uid" = :db_condition_placeholder_0) AND ("provider" = :db_condition_placeholder_1)
LIMIT 1 OFFSET 0', Array, Array) (Line: 525)
Drupal\Core\Database\Query\Select->execute() (Line: 63)
Drupal\externalauth\Authmap->get(2, 'samlauth') (Line: 118)
samlauth_check_saml_user(Array, Object)
call_user_func_array('samlauth_check_saml_user', Array) (Line: 82)
Drupal\Core\Form\FormValidator->executeValidateHandlers(Array, Object) (Line: 275)
Drupal\Core\Form\FormValidator->doValidateForm(Array, Object, 'user_login_form') (Line: 118)
Drupal\Core\Form\FormValidator->validateForm('user_login_form', Array, Object) (Line: 593)
Drupal\Core\Form\FormBuilder->processForm('user_login_form', Array, Object) (Line: 325)
Drupal\Core\Form\FormBuilder->buildForm(Object, Object) (Line: 73)
Drupal\Core\Controller\FormController->getContentResult(Object, Object)
call_user_func_array(Array, Array) (Line: 123)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 121)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}() (Line: 181)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Additionally, when I go to configure the SAML Auth, the Links tab results in the below error:
The website encountered an unexpected error. Please try again later.
Drupal\Core\Database\DatabaseExceptionWrapper: Exception in SAML Authentication Links[samlauth_map]: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cab.authmap' doesn't exist: SELECT "authmap"."authname" AS "authmap_authname", "authmap"."uid" AS "authmap_uid", "users_field_data_authmap"."uid" AS "users_field_data_authmap_uid" FROM "authmap" "authmap" LEFT JOIN "users_field_data" "users_field_data_authmap" ON authmap.uid = users_field_data_authmap.uid WHERE "authmap"."provider" LIKE :db_condition_placeholder_0 ESCAPE '\\' ORDER BY "authmap_authname" ASC LIMIT 51 OFFSET 0; Array ( [:db_condition_placeholder_0] => samlauth ) in main() (line 19 of index.php).
Drupal\views\ViewExecutable->execute(NULL) (Line: 1469)
Drupal\views\ViewExecutable->render() (Line: 199)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1645)
Drupal\views\ViewExecutable->executeDisplay('page', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 797)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 386)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Steps to reproduce
First, I took a look at the README and attempted to go through the steps.
I installed the module using:
composer require 'drupal/samlauth:^3.9'
Then I went into the extend menu and enabled the following:
- External Authentication
- SAML Authentication
- SAML Auth User Fields Mapping
- SAML Auth User Role Assignment
For me, this is all it takes for the issues to start.
I attempted some solutions described below but all were unsuccessful. I did not proceed further with the setup because I have to push this to my staging server before configuring it, and as I am unable to login while these modules are installed, I am not be able to login as an admin to configure the module, so I rolled back.
Uninstalling the module completely gets rid of the bugs.
Attempted Solutions
1) I thought that maybe there are tables to create/update so I ran drush updb
which said there were no pending updates.
2) The readme stated that a UI exists for the authmap at admin/config/people/saml/authmap
so I attempted to visit this link to see if there is a function there to create the authmap table. This immediately threw a similar error to before:
The website encountered an unexpected error. Please try again later.
Drupal\Core\Database\DatabaseExceptionWrapper: Exception in SAML Authentication Links[samlauth_map]: SQLSTATE[42S02]: Base table or view not found: 1146 Table 'cab.authmap' doesn't exist: SELECT "authmap"."authname" AS "authmap_authname", "authmap"."uid" AS "authmap_uid", "users_field_data_authmap"."uid" AS "users_field_data_authmap_uid" FROM "authmap" "authmap" LEFT JOIN "users_field_data" "users_field_data_authmap" ON authmap.uid = users_field_data_authmap.uid WHERE "authmap"."provider" LIKE :db_condition_placeholder_0 ESCAPE '\\' ORDER BY "authmap_authname" ASC LIMIT 51 OFFSET 0; Array ( [:db_condition_placeholder_0] => samlauth ) in main() (line 19 of index.php).
Drupal\views\ViewExecutable->execute(NULL) (Line: 1469)
Drupal\views\ViewExecutable->render() (Line: 199)
Drupal\views\Plugin\views\display\Page->execute() (Line: 1645)
Drupal\views\ViewExecutable->executeDisplay('page', Array) (Line: 81)
Drupal\views\Element\View::preRenderViewElement(Array)
call_user_func_array(Array, Array) (Line: 111)
Drupal\Core\Render\Renderer->doTrustedCallback(Array, Array, 'Render #pre_render callbacks must be methods of a class that implements \Drupal\Core\Security\TrustedCallbackInterface or be an anonymous function. The callback was %s. See https://www.drupal.org/node/2966725', 'exception', 'Drupal\Core\Render\Element\RenderCallbackInterface') (Line: 797)
Drupal\Core\Render\Renderer->doCallback('#pre_render', Array, Array) (Line: 386)
Drupal\Core\Render\Renderer->doRender(Array, ) (Line: 204)
Drupal\Core\Render\Renderer->render(Array, ) (Line: 238)
Drupal\Core\Render\MainContent\HtmlRenderer->Drupal\Core\Render\MainContent\{closure}() (Line: 592)
Drupal\Core\Render\Renderer->executeInRenderContext(Object, Object) (Line: 231)
Drupal\Core\Render\MainContent\HtmlRenderer->prepare(Array, Object, Object) (Line: 128)
Drupal\Core\Render\MainContent\HtmlRenderer->renderResponse(Array, Object, Object) (Line: 90)
Drupal\Core\EventSubscriber\MainContentViewSubscriber->onViewRenderArray(Object, 'kernel.view', Object)
call_user_func(Array, Object, 'kernel.view', Object) (Line: 111)
Drupal\Component\EventDispatcher\ContainerAwareEventDispatcher->dispatch(Object, 'kernel.view') (Line: 186)
Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object, 1) (Line: 76)
Symfony\Component\HttpKernel\HttpKernel->handle(Object, 1, 1) (Line: 58)
Drupal\Core\StackMiddleware\Session->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object, 1, 1) (Line: 106)
Drupal\page_cache\StackMiddleware\PageCache->pass(Object, 1, 1) (Line: 85)
Drupal\page_cache\StackMiddleware\PageCache->handle(Object, 1, 1) (Line: 48)
Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object, 1, 1) (Line: 51)
Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object, 1, 1) (Line: 704)
Drupal\Core\DrupalKernel->handle(Object) (Line: 19)
Summary
Does anybody know how to fix this error and install this module successfully? It sounds like the authmap table failed to generate, but I am not sure what I can do to force it to re-generate.