Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

pgwire,auth: support pg's auth username maps #47196

Closed
knz opened this issue Apr 8, 2020 · 0 comments · Fixed by #70269
Closed

pgwire,auth: support pg's auth username maps #47196

knz opened this issue Apr 8, 2020 · 0 comments · Fixed by #70269
Assignees
Labels
A-authentication Pertains to authn subsystems A-cc-enablement Pertains to current CC production issues or short-term projects A-security A-sql-pgwire pgwire protocol issues. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-server-and-security DB Server & Security X-server-triaged-202105

Comments

@knz
Copy link
Contributor

knz commented Apr 8, 2020

In crdb 19.1, we have introduced support for PostgreSQL's (obsolete!) include_realm option for GSSAPI authentication, which maps Kerberos usernames to database usernames by stripping the realm suffix.

In crdb 20.1, we have introduced --cert-principal-map to satisfy some Amazon IAM (ACM) UX issues.

It turns out that PostgreSQL already has a common, uniform protocol to do this: https://www.postgresql.org/docs/12/auth-username-maps.html (we didn't know about this when we did the work for v19.1/v20.1).

How the pg thing would translate to crdb:

  • create a new cluster setting alongside server.host_based_authentication.configuration to hold the equivalent of pg's pg_ident.conf
  • enable HBA rules to refer to maps defined in pg_ident.conf
  • deprecate include_realm for GSSAPI (like it is already deprecated in postgres) and replace it by uniform use of name mappings.
@knz knz added C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) A-sql-pgwire pgwire protocol issues. A-security labels Apr 8, 2020
@jlinder jlinder added the T-server-and-security DB Server & Security label Jun 16, 2021
@bobvawter bobvawter self-assigned this Jul 16, 2021
@knz knz added A-authentication Pertains to authn subsystems A-cc-enablement Pertains to current CC production issues or short-term projects labels Jul 29, 2021
craig bot pushed a commit that referenced this issue Nov 18, 2021
70269: pgwire: Add dynamic user identity mapping r=bobvawter a=bobvawter

This commit adds support for mapping incoming system usernames (e.g.: GSSAPI
principals, X.509 Common Names) to database usernames. The implementation
follows in the same pattern as the HBA configuration. Namely, there is a new
cluster setting server.identity_map.configuration which contains data
compatible with the pg_ident.conf file.

When a new connection is made, the relevant HBA configuration line is selected
and the "map" option is used to select an identity-map ruleset. The system
username is mapped to a database username and authentication proceeds against
the database username.

The default HBA configuration is updated to add a "map=cockroach-default"
option. This allows users who are solely interested in providing system
username mappings to install an identity-map without also needing to provide an
HBA configuration.

For pedantry's sake, the term "identity" is preferred over "username" within
the code, since not all identities are necessarily what would be considered
usernames.

Fixes: #47196

Release note (security update): The server.identity_map.configuration cluster
setting allows a pg_ident.conf file to be uploaded to support dynamically
remapping system usernames (e.g.: Kerberos principals, X.509 Common Names) to
database usernames.

72774: sql: improve a test r=andreimatei a=andreimatei

This test was deadlocking on t.Fatal(). I've ran into this through #72769.

Release note: None

72878: sem/tree: protect against double panic in EvalCtx.Stop r=andreimatei a=andreimatei

Sometimes in tests EvalCtx.Stop() is called in a defer. When the defer
runs because of a panic, it would likely panic again because its memory
monitor is not empty.

Release note: None

Co-authored-by: Bob Vawter <bob@vawter.org>
Co-authored-by: Andrei Matei <andrei@cockroachlabs.com>
@craig craig bot closed this as completed in eaeb574 Nov 18, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-authentication Pertains to authn subsystems A-cc-enablement Pertains to current CC production issues or short-term projects A-security A-sql-pgwire pgwire protocol issues. C-enhancement Solution expected to add code/behavior + preserve backward-compat (pg compat issues are exception) T-server-and-security DB Server & Security X-server-triaged-202105
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants