Commit 51692f5e authored by Märt Rang's avatar Märt Rang
Browse files

Issue #3202134: Implement Smart-ID for Latvia, Lithuania, support Drupal 10

parent 25fc07f2
Loading
Loading
Loading
Loading
+1 −0
Changes for config/install/eid_auth.settings.yml: 1 added line, 0 removed lines.
Original line number Diff line number Diff line
@@ -9,6 +9,7 @@ smart_id_relying_party_name: DEMO
smart_id_host_url: 'https://sid.demo.sk.ee/smart-id-rp/v1/'
smart_id_resource_location: ../certs
smart_id_display_message: 'Log in'
smart_id_country: 'EE'
enabled_auth_methods:
  id_card: id_card
  mobile_id: mobile_id
+3 −0
Changes for config/schema/eid_auth.schema.yml: 3 added lines, 0 removed lines.
Original line number Diff line number Diff line
@@ -41,6 +41,9 @@ eid_auth.settings:
    smart_id_display_message:
      type: label
      label: 'SmartID display message'
    smart_id_country:
      type: string
      label: 'Country code'
    login_redirect:
      type: string
      label: 'Login redirect'
+1 −1
Changes for eid_auth.info.yml: 1 added line, 1 removed line.
Original line number Diff line number Diff line
@@ -3,7 +3,7 @@ description: "Estonian ID-card and Mobile ID authentication"
package: Authentication

type: module
core_version_requirement: ^9
core_version_requirement: ^9|^10

dependencies:
  - drupal:user
+7 −12
Changes for src/Authentication/EidAuthentication.php: 7 added lines, 12 removed lines.
Original line number Diff line number Diff line
@@ -82,6 +82,8 @@ class EidAuthentication {
  public static function findUserByPersonalIdCode($personal_id_code) {
    $query = \Drupal::entityQuery('user');
    $query->condition('field_personal_id_code', $personal_id_code);
    // Most likely access check shouldn't be done here.
    $query->accessCheck(FALSE);
    $uids = $query->execute();

    if (empty($uids)) {
@@ -99,20 +101,13 @@ class EidAuthentication {
   *
   * @return bool|string|null
   */
  public static function smartIdExtractUserPersonalIdCode($personal_id_code) {

    $pos = strpos($personal_id_code, '-');
  public static function smartIdExtractUserPersonalIdCode($personal_id_code): ?string {
    $matches = NULL;
    preg_match('/(\d{11})|(\d{6}-\d{5})/', $personal_id_code, $matches);

    $extracted_id = NULL;
    if ($pos !== FALSE) {

      $country_code = substr($personal_id_code, 3, 2);
      if ($country_code !== 'EE') {

        exit('Wrong country!');
      }

      $extracted_id = substr($personal_id_code, $pos + 1);
    if ($matches) {
      $extracted_id = $matches[0];
    }

    return $extracted_id;
+3 −2
Changes for src/Controller/SmartIdController.php: 3 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -79,11 +79,12 @@ class SmartIdController extends ControllerBase {
   */
  public function smartIdCheck() {
    $commands = new AjaxResponse();
    $config = $config = $this->config('eid_auth.settings');
    $config = $this->config('eid_auth.settings');
    $country = $config->get('smart_id_country') ?? 'EE';

    $semanticsIdentifier = SemanticsIdentifier::builder()
      ->withSemanticsIdentifierType('PNO')
      ->withCountryCode('EE')
      ->withCountryCode($country)
      ->withIdentifier($this->store->get('national_identity_number'))
      ->build();

Loading