OpenConext / Stepup-Project

Managing issues for Stepup-* projects
0 stars 0 forks source link

Allowed second factor unique constraint violation error when pushing config #206

Closed phavekes closed 3 days ago

phavekes commented 3 days ago

This issue is imported from pivotal - Originaly created at Apr 3, 2018 by Michiel Kodde

**Steps to reproduce**
  1. Start by pushing institution config with whitelisted allowed_second_factors. For example:
    // example 1
    {
        "institution-a.nl": {
            "use_ra_locations": true,
            "show_raa_contact_information": false,
            "verify_email":false,
            "allowed_second_factors": ["sms", "tiqr"]
        }
    }
  2. Now remove one of the token types from the allowed_second_factors.
    // example 2
    {
        "institution-a.nl": {
            "use_ra_locations": true,
            "show_raa_contact_information": false,
            "verify_email":false,
            "allowed_second_factors": ["sms"]
        }
    }
  3. You are treated with a: Doctrine\\DBAL\\Exception\\UniqueConstraintViolationException: An exception occurred while executing ‘INSERT INTO allowed_second_factor (institution, second_factor_type)...

Expected behaviour After push of example 1 the middleware projection for institution a should look like:

institution second_factor_type
institution-a.nl sms
institution-a.nl tiqr

After push of example 2 the projection should look like:

institution second_factor_type
institution-a.nl sms

Workaround Push an empty list of allowed_second_factors effectively emptying the allowed_second_factors projection for the institution. And then push the new values.

Code change https://github.com/OpenConext/Stepup-Middleware/pull/217

Relates to

119815553

https://github.com/OpenConext/Stepup-Middleware/pull/176

phavekes commented 3 days ago

Verified that adding and removing a token type for an institution is correctly reflected in the allowed_second_factor table. (Pieter van der Meulen - Apr 18, 2018)