mirror of
https://github.com/authelia/authelia.git
synced 2026-10-28 09:34:52 +08:00
`GenerateOpaqueUserID` loaded the opaque identifier for a user and sector and inserted a new one when none existed, with nothing guarding the gap between the two. Two first time authorizations for the same user and sector which arrived together both found no identifier, and the second insert failed on the unique constraint over `service`, `sector_id` and `username`, which ended its authorization with `ErrSubjectCouldNotLookup`. The `OIDCConformance` suite hits this whenever its plans authorize `john` in the same instant, which shows up as `duplicate key value violates unique constraint "user_opaque_identifier_service_sector_id_username_key"` in the PostgreSQL log. When the insert fails on a unique constraint the identifier which won is now loaded and returned, so every request resolves the same subject. `storage.IsUniqueConstraintViolation` recognizes the violation on SQLite, MySQL and PostgreSQL. Signed-off-by: Amir Zarrinkafsh <3339418+nightah@users.noreply.github.com>