Protocol can't be deleted after federated_user is created

Bug #1642692 reported by Rodrigo Duarte
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
OpenStack Identity (keystone)
Fix Released
Medium
Rodrigo Duarte

Bug Description

When authenticating a user via federation, a federated_user entry is created in keystone's database, an example of such entry is below:

mysql> select * from federated_user;
+----+----------------------------------+----------+-------------+-----------------------+---------------------+
| id | user_id | idp_id | protocol_id | unique_id | display_name |
+----+----------------------------------+----------+-------------+-----------------------+---------------------+
| 1 | 15ddf8fda20842c68b99999b6d91d1a7 | testshib | mapped | myself%40testshib.org | <email address hidden> |
+----+----------------------------------+----------+-------------+-----------------------+---------------------+

The federated_user_protocol_id foreign key prevents the protocol deletion:

Details: An unexpected error prevented the server from fulfilling your request: (pymysql.err.IntegrityError) (1451, u'Cannot delete or update a parent row: a foreign key constraint fails (`keystone`.`federated_user`, CONSTRAINT `federated_user_protocol_id_fkey` FOREIGN KEY (`protocol_id`, `idp_id`) REFERENCES `federation_protocol` (`id`, `idp_id`))') [SQL: u'DELETE FROM federation_protocol WHERE federation_protocol.id = %(id)s AND federation_protocol.idp_id = %(idp_id)s'] [parameters: {'idp_id': u'testshib', 'id': u'mapped'}]

This can be also happening with the "idp_id" column as well.

This prevents automated tests like [1] to properly work, since it creates and destroys the identity provider, mapping and protocol during its execution.

[1] https://review.openstack.org/#/c/324769/

Changed in keystone:
assignee: nobody → Ron De Rose (ronald-de-rose)
Revision history for this message
Adam Young (ayoung) wrote :

I would expect that the shadow user table would refer to the protocol via that key. In order to delete the protocol, we would need to delete all the entries that came in via that protocol. This should be possible with a cascading delete. But we might need to make this deliberate inside the Keystone Federation code.

Changed in keystone:
status: New → Triaged
importance: Undecided → Medium
tags: added: federation
tags: added: test-improvement
Revision history for this message
Rodrigo Duarte (rodrigodsousa) wrote :

The protocol_id column doesn't have a direct reference to the federation_protocol table, instead, we have the following:

    migrate.ForeignKeyConstraint(
        columns=[federated_table.c.protocol_id, federated_table.c.idp_id],
        refcolumns=[protocol_table.c.id, protocol_table.c.idp_id]).create()

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Related fix merged to keystone (master)

Reviewed: https://review.openstack.org/324769
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=647b83d72375b59cce4dd16c0f428d304534bbb0
Submitter: Jenkins
Branch: master

commit 647b83d72375b59cce4dd16c0f428d304534bbb0
Author: Rodrigo Duarte <email address hidden>
Date: Thu Jun 2 16:08:39 2016 -0300

    Federated authentication via ECP functional tests

    Adds a first test for the federated authentication feature. It handles
    first the authentication using the SAML2 ECP profile.

    The tests cleanup have some issues, see related bug.

    Related-Bug: 1642692
    Change-Id: I3b393a695c6d9f846efdaf302c1beea34e6bd54b

Changed in keystone:
assignee: Ron De Rose (ronald-de-rose) → Rodrigo Duarte (rodrigodsousa)
status: Triaged → In Progress
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to keystone (master)

Reviewed: https://review.openstack.org/415906
Committed: https://git.openstack.org/cgit/openstack/keystone/commit/?id=45f7ff3918ce8d05585d1c2e1740462e711965fe
Submitter: Jenkins
Branch: master

commit 45f7ff3918ce8d05585d1c2e1740462e711965fe
Author: Rodrigo Duarte Sousa <email address hidden>
Date: Tue Jan 3 10:41:07 2017 -0300

    Cascade delete federated_user fk

    The bug was caused by a foreign key in the federated_user table. This
    key prevents a protocol from being deleted after a successful
    authentication has happened (so the creation of a federated user
    via shadowing). We take advantage of the same foreign key by adding the
    cascade delete behavior to it.

    Closes-Bug: 1642692

    Change-Id: I3b3e265d20f0cfe0ee10c6a274d9bdf4e840b742

Changed in keystone:
status: In Progress → Fix Released
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to keystone (stable/newton)

Fix proposed to branch: stable/newton
Review: https://review.openstack.org/420893

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix included in openstack/keystone 11.0.0.0b3

This issue was fixed in the openstack/keystone 11.0.0.0b3 development milestone.

Changed in keystone:
milestone: none → ocata-3
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Change abandoned on keystone (stable/newton)

Change abandoned by Rodrigo Duarte (<email address hidden>) on branch: stable/newton
Review: https://review.openstack.org/420893
Reason: abandoning since this is the wrong approach and should have not been merged in the first place

Revision history for this message
OpenStack Infra (hudson-openstack) wrote :

Change abandoned by Tony Breeds (<email address hidden>) on branch: stable/newton
Review: https://review.openstack.org/420893
Reason: This branch (stable/newton) is at End Of Life

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.