reverted: --- b/config/install/simplesamlphp_auth.settings.yml +++ a/config/install/simplesamlphp_auth.settings.yml @@ -15,7 +15,6 @@ default_login: true default_login_roles: [] default_login_users: '1' -change_login_default_path: false logout_goto_url: user_register_original: sync: reverted: --- b/config/schema/simplesamlphp_auth.schema.yml +++ a/config/schema/simplesamlphp_auth.schema.yml @@ -60,9 +60,6 @@ default_login_users: type: string label: 'Users to be allowed to log in locally' - change_login_default_path: - type: boolean - label: 'Log in directly with external IdP.' logout_goto_url: type: string label: 'Redirect users after logging out' reverted: --- b/simplesamlphp_auth.services.yml +++ a/simplesamlphp_auth.services.yml @@ -5,11 +5,6 @@ simplesamlphp_auth.drupalauth: class: Drupal\simplesamlphp_auth\Service\SimplesamlphpDrupalAuth arguments: ['@simplesamlphp_auth.manager', '@config.factory', '@entity.manager', '@logger.channel.simplesamlphp_auth', '@externalauth.externalauth', '@current_user'] - simplesamlphp_auth.route_subscriber: - class: Drupal\simplesamlphp_auth\Routing\RouteSubscriber - arguments: ['@config.factory'] - tags: - - { name: event_subscriber } simplesamlphp_auth_event_subscriber: class: Drupal\simplesamlphp_auth\EventSubscriber\SimplesamlSubscriber arguments: ['@simplesamlphp_auth.manager', '@current_user', '@config.factory', '@logger.channel.simplesamlphp_auth'] reverted: --- b/src/Form/LocalSettingsForm.php +++ a/src/Form/LocalSettingsForm.php @@ -46,12 +46,6 @@ '#default_value' => $config->get('allow.default_login'), '#description' => $this->t('Check this box if you want to let people log in with local Drupal accounts (without using simpleSAMLphp). If you want to restrict this privilege to certain users you can enter the Drupal user IDs in the field below.'), ); - $form['authentication']['change_login_default_path'] = array( - '#type' => 'checkbox', - '#title' => $this->t('Log in directly with external IdP.'), - '#default_value' => $config->get('change_login_default_path'), - '#description' => $this->t('Check this box if you want people being redirected to your IdP login page instead of being shown the standard login Drupal page.'), - ); $form['authentication']['allow_set_drupal_pwd'] = array( '#type' => 'checkbox', '#title' => $this->t('Allow SAML users to set Drupal passwords'), @@ -90,20 +84,12 @@ parent::submitForm($form, $form_state); $config = $this->config('simplesamlphp_auth.settings'); - $change_login_default_path_old = $config->get('change_login_default_path'); - $config->set('allow.default_login', $form_state->getValue('allow_default_login')); - $config->set('change_login_default_path', $form_state->getValue('change_login_default_path')); $config->set('allow.set_drupal_pwd', $form_state->getValue('allow_set_drupal_pwd')); $config->set('allow.default_login_roles', $form_state->getValue('allow_default_login_roles')); $config->set('allow.default_login_users', $form_state->getValue('allow_default_login_users')); $config->set('logout_goto_url', $form_state->getValue('logout_goto_url')); - $config->save(); - - if ($config->get('change_login_default_path') !== $change_login_default_path_old) { - \Drupal::service("router.builder")->rebuild(); - } } } reverted: --- b/src/Routing/RouteSubscriber.php +++ /dev/null @@ -1,39 +0,0 @@ -config = $config_factory->get('simplesamlphp_auth.settings'); - } - - /** - * {@inheritdoc} - */ - public function alterRoutes(RouteCollection $collection) { - if ($this->config->get('change_login_default_path')) { - if ($route = $collection->get('user.login')) { - $route->setPath('/saml_login'); - } - } - } - -} only in patch2: unchanged: --- a/config/install/simplesamlphp_auth.settings.yml +++ b/config/install/simplesamlphp_auth.settings.yml @@ -16,6 +16,7 @@ allow: default_login: true default_login_roles: [] default_login_users: '1' +change_login_default_path: false logout_goto_url: user_register_original: sync: only in patch2: unchanged: --- a/config/schema/simplesamlphp_auth.schema.yml +++ b/config/schema/simplesamlphp_auth.schema.yml @@ -60,6 +60,9 @@ simplesamlphp_auth.settings: default_login_users: type: string label: 'Users to be allowed to log in locally' + change_login_default_path: + type: boolean + label: 'Log in directly with external IdP.' logout_goto_url: type: string label: 'Redirect users after logging out' only in patch2: unchanged: --- a/simplesamlphp_auth.services.yml +++ b/simplesamlphp_auth.services.yml @@ -5,6 +5,11 @@ services: simplesamlphp_auth.drupalauth: class: Drupal\simplesamlphp_auth\Service\SimplesamlphpDrupalAuth arguments: ['@simplesamlphp_auth.manager', '@config.factory', '@entity_type.manager', '@logger.channel.simplesamlphp_auth', '@externalauth.externalauth', '@current_user'] + simplesamlphp_auth.route_subscriber: + class: Drupal\simplesamlphp_auth\Routing\RouteSubscriber + arguments: ['@config.factory'] + tags: + - { name: event_subscriber } simplesamlphp_auth_event_subscriber: class: Drupal\simplesamlphp_auth\EventSubscriber\SimplesamlSubscriber arguments: ['@simplesamlphp_auth.manager', '@current_user', '@config.factory', '@logger.channel.simplesamlphp_auth'] only in patch2: unchanged: --- a/src/Form/LocalSettingsForm.php +++ b/src/Form/LocalSettingsForm.php @@ -41,6 +41,12 @@ class LocalSettingsForm extends ConfigFormBase { '#default_value' => $config->get('allow.default_login'), '#description' => $this->t('Check this box if you want to let people log in with local Drupal accounts (without using simpleSAMLphp). If you want to restrict this privilege to certain users you can enter the Drupal user IDs in the field below.'), ]; + $form['authentication']['change_login_default_path'] = array( + '#type' => 'checkbox', + '#title' => $this->t('Log in directly with external IdP.'), + '#default_value' => $config->get('change_login_default_path'), + '#description' => $this->t('Check this box if you want people being redirected to your IdP login page instead of being shown the standard login Drupal page.'), + ); $form['authentication']['allow_set_drupal_pwd'] = [ '#type' => 'checkbox', '#title' => $this->t('Allow SAML users to set Drupal passwords'), @@ -79,12 +85,21 @@ class LocalSettingsForm extends ConfigFormBase { parent::submitForm($form, $form_state); $config = $this->config('simplesamlphp_auth.settings'); + $change_login_default_path_old = $config->get('change_login_default_path'); + + $config->set('allow.default_login', $form_state->getValue('allow_default_login')); + $config->set('change_login_default_path', $form_state->getValue('change_login_default_path')); $config->set('allow.set_drupal_pwd', $form_state->getValue('allow_set_drupal_pwd')); $config->set('allow.default_login_roles', $form_state->getValue('allow_default_login_roles')); $config->set('allow.default_login_users', $form_state->getValue('allow_default_login_users')); $config->set('logout_goto_url', $form_state->getValue('logout_goto_url')); + $config->save(); + + if ($config->get('change_login_default_path') !== $change_login_default_path_old) { + \Drupal::service("router.builder")->rebuild(); + } } } only in patch2: unchanged: --- /dev/null +++ b/src/Routing/RouteSubscriber.php @@ -0,0 +1,39 @@ +config = $config_factory->get('simplesamlphp_auth.settings'); + } + + /** + * {@inheritdoc} + */ + public function alterRoutes(RouteCollection $collection) { + if ($this->config->get('change_login_default_path')) { + if ($route = $collection->get('user.login')) { + $route->setPath('/saml_login'); + } + } + } + +}