You are here

function acsf_sso_install in Acquia Cloud Site Factory Connector 8.2

Same name and namespace in other branches
  1. 8 acsf_sso/acsf_sso.install \acsf_sso_install()

Implements hook_install().

File

acsf_sso/acsf_sso.install, line 75
The install tasks of the acsf_sso module.

Code

function acsf_sso_install() {
  $site = AcsfSite::load();
  if (empty($site->saml_keys)) {
    $site
      ->initSamlKeyProperties();
  }
  $common_config = [
    'sp_name_id_format' => 'urn:oasis:names:tc:SAML:2.0:nameid-format:transient',
    'unique_id_attribute' => 'urn:oid:2.5.4.45',
    'create_users' => 1,
    'map_users' => 1,
    'sync_name' => 1,
    'sync_mail' => 1,
    'user_name_attribute' => 'urn:oid:2.5.4.41',
    'user_mail_attribute' => 'urn:oid:0.9.2342.19200300.100.1.3',
    'security_authn_requests_sign' => 1,
    'security_messages_sign' => 1,
    'strict' => 1,
    'idp_entity_id' => $site->factory_url . '/sso/saml2/idp/metadata.php',
    'idp_single_sign_on_service' => $site->factory_url . '/sso/saml2/idp/SSOService.php',
    'idp_single_log_out_service' => $site->factory_url . '/sso/saml2/idp/SingleLogoutService.php',
    'sp_private_key' => $site->saml_keys['sp_private_key'],
    'sp_x509_certificate' => $site->saml_keys['sp_x509_certificate'],
    'idp_x509_certificate' => $site->saml_keys['idp_x509_certificate'],
  ];
  $config = \Drupal::configFactory()
    ->getEditable('samlauth.authentication');
  foreach ($common_config as $key => $sso_config) {
    $config
      ->set($key, $sso_config);
  }
  $config
    ->save();
}