Uploaded image for project: 'Crowd'
  1. Crowd
  2. CWD-3882

Add unique constraint on columns external_id and directory_id

    Details

    • Type: Improvement
    • Status: Open
    • Priority: Medium
    • Resolution: Unresolved
    • Affects Version/s: None
    • Fix Version/s: None
    • Component/s: None
    • Labels:
      None

      Description

      In the table cwd_user, there should be no rows where the external_id is repeated for the same directory_id. Said in another way, the external_id should be unique for the same directory_id.

      To avoid this from causing problems, we should add a unique constraint at a database level in the table cwd_user.

      When two users share external_id and directory_id, the user is not able to login or update new information from the external user directory. Those actions will fail with the following error:

      org.springframework.dao.IncorrectResultSizeDataAccessException: query did not return a unique result: 2
              at org.springframework.orm.hibernate.SessionFactoryUtils.convertHibernateAccessException(SessionFactoryUtils.java:590)
              at org.springframework.orm.hibernate.HibernateAccessor.convertHibernateAccessException(HibernateAccessor.java:353)
              at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:375)
              at org.springframework.orm.hibernate.HibernateTemplate.execute(HibernateTemplate.java:337)
              at com.atlassian.crowd.embedded.hibernate2.HibernateUserDao.internalFindUserByExternalId(HibernateUserDao.java:501)
              at com.atlassian.crowd.embedded.hibernate2.HibernateUserDao.internalFindByExternalId(HibernateUserDao.java:473)
              at com.atlassian.crowd.embedded.hibernate2.HibernateUserDao.findByExternalId(HibernateUserDao.java:449)
              at com.atlassian.confluence.user.crowd.CachedCrowdUserDao.findByExternalId(CachedCrowdUserDao.java:164)
      ...

      This also affects embedded Crowd.

        Attachments

          Issue Links

            Activity

              People

              • Votes:
                6 Vote for this issue
                Watchers:
                15 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Last commented:
                  11 weeks ago