Skip to content

Commit

Permalink
Merge pull request #22 from City-of-Helsinki/UHF-8382
Browse files Browse the repository at this point in the history
UHF-8382
  • Loading branch information
rpnykanen authored May 17, 2023
2 parents 653e931 + cd75be1 commit 17badf6
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 7 deletions.
12 changes: 5 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,6 @@
Tunnistamo client should be enabled automatically, but in case it wasn't, you can
enable `tunnistamo` client from `/admin/config/services/openid-connect`.

### Upgrading from 1.x to 2.x

- Run `composer require "drupal/helfi_tunnistamo:^2.0" -W` in your project's root
- Run database updates: `drush updb -y`
- Delete old openid_connect clients: `rm conf/cmi/openid_connect.settings.facebook.yml conf/cmi/openid_connect.settings.generic.yml conf/cmi/openid_connect.settings.github.yml conf/cmi/openid_connect.settings.google.yml conf/cmi/openid_connect.settings.linkedin.yml conf/cmi/openid_connect.settings.tunnistamo.yml`
- Re-create tunnistamo client from `/admin/config/people/openid-connect`

## Redirect URL

`https://example.com/openid-connect/tunnistamo`
Expand All @@ -32,6 +25,11 @@ $config['openid_connect.client.tunnistamo']['settings']['client_secret'] = geten
$config['openid_connect.client.tunnistamo']['settings']['environment_url'] = getenv('TUNNISTAMO_ENVIRONMENT_URL');
```

## Local development

TBD: How to set up tunnistamo-authentication on local development environment.
https://helsinkisolutionoffice.atlassian.net/wiki/spaces/HEL/pages/8283226135/Helfi-tunnistamo+moduuli

## Contact

Slack: #helfi-drupal (http://helsinkicity.slack.com/)
Expand Down
1 change: 1 addition & 0 deletions helfi_tunnistamo.module
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ function helfi_tunnistamo_openid_connect_post_authorize(UserInterface $account,
return;
}
$plugin->mapRoles($account);
$plugin->setUserPreferredAdminLanguage($account);
}

/**
Expand Down
21 changes: 21 additions & 0 deletions src/Plugin/OpenIDConnectClient/Tunnistamo.php
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,25 @@ public function getClientScopes(): array {
return explode(',', $this->configuration['client_scopes']);
}

/**
* Set user preferred admin langcode if not set.
*
* @param \Drupal\user\UserInterface $account
* Account.
*/
public function setUserPreferredAdminLanguage(UserInterface $account) : void {
try {
if (
$this->environmentResolver->getActiveProject() &&
!$account->getPreferredAdminLangcode(FALSE)
) {
$account->set('preferred_admin_langcode', 'fi');
$account->save();
}
}
catch (\Exception $e) {
return;
}
}

}

0 comments on commit 17badf6

Please sign in to comment.