You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sql: prevent auth failure when no roles are granted during sync
Previously, the EnsureUserOnlyBelongsToRoles function would construct
and execute a GRANT statement even if the list of roles to grant was
empty after filtering for roles that exist in the database.
This was inadequate because it caused authentication to fail for users
logging in via external providers (LDAP, JWT, OIDC). If a user
belonged to external groups that did not map to any existing roles in
CockroachDB, the function would generate an invalid SQL statement
(GRANT TO <user>), resulting in a syntax error that blocked the user's
session.
To address this, this patch modifies EnsureUserOnlyBelongsToRoles to
only build and execute the GRANT statement if at least one valid,
existing role is being granted. This prevents the syntax error and
allows users to log in successfully even if their external group
memberships do not result in any new role grants.
This commit also adds unit tests for `EnsureUserOnlyBelongsToRoles()`.
Fixes: #143878
Release note (bug fix): Fixed a bug where database login could fail
during LDAP, JWT, or OIDC authentication if the user's external group
memberships did not correspond to any existing roles in the
database. The login will now succeed, and no roles will be granted or
revoked in this scenario.
0 commit comments