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

sql/pgwire: treat system identity as string, not SQLUsername #130979

Merged
merged 1 commit into from
Sep 19, 2024

Conversation

rafiss
Copy link
Collaborator

@rafiss rafiss commented Sep 18, 2024

The external system identity may not be a SQLUsername -- that mapping is performed at a different phase of authentication. To make this more clear, we stop using the SQLUsername type for system identity.

Epic CRDB-33829
Release note: None

Copy link

blathers-crl bot commented Sep 18, 2024

It looks like your PR touches production code but doesn't add or edit any test code. Did you consider adding tests to your PR?

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@cockroach-teamcity
Copy link
Member

This change is Reviewable

@rafiss rafiss force-pushed the system-identity-string branch 2 times, most recently from 6fb96b8 to ebd5b1e Compare September 19, 2024 05:38
@rafiss rafiss marked this pull request as ready for review September 19, 2024 05:40
@rafiss rafiss requested review from a team as code owners September 19, 2024 05:40
@rafiss rafiss force-pushed the system-identity-string branch 5 times, most recently from e03e150 to f97c176 Compare September 19, 2024 06:26
Copy link
Contributor

@souravcrl souravcrl left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 14 of 17 files at r1, 1 of 1 files at r2, 3 of 3 files at r3, all commit messages.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @pritesh-lahoti and @rafiss)


pkg/sql/pgwire/auth.go line 185 at r3 (raw file):

	// in. Now we can delegate to the selected AuthMethod implementation to
	// complete the authentication. We must pass in the systemIdentity here,
	// since the authenticator may use an external source to verify the

This makes it clear now. Thank you for pointing this out.


pkg/sql/pgwire/auth_methods.go line 920 at r3 (raw file):

	})
	b := &AuthBehaviors{}
	b.SetRoleMapper(UseSpecifiedIdentity(sessionUser))

This was tricky previously with UseProvidedIdentity. This would solve it when we want to use a different identity for behaviors.MapRole and behaviors.Authenticate.


pkg/sql/pgwire/auth_methods.go line 943 at r3 (raw file):

		// Verify that the systemIdentity is what we expect.
		if ldapUserDN.String() != systemIdentity {
			err := errors.New("LDAP user DN mismatch")

nit: we can log the ldapUserDN and systemIdentity here incase of mismatch

Suggestion:

	err := errors.Newf("LDAP user DN mismatch, expected user DN: %s, obtained systemIdentity: %s", ldapUserDN.String(), systemIdentity)

@rafiss
Copy link
Collaborator Author

rafiss commented Sep 19, 2024

TFTR!

bors r+

Copy link
Collaborator Author

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @pritesh-lahoti and @souravcrl)


pkg/sql/pgwire/auth_methods.go line 943 at r3 (raw file):

Previously, souravcrl wrote…

nit: we can log the ldapUserDN and systemIdentity here incase of mismatch

done

@craig
Copy link
Contributor

craig bot commented Sep 19, 2024

Build failed:

@rafiss
Copy link
Collaborator Author

rafiss commented Sep 19, 2024

bors retry

@craig
Copy link
Contributor

craig bot commented Sep 19, 2024

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Sep 19, 2024

Build failed (retrying...):

@craig
Copy link
Contributor

craig bot commented Sep 19, 2024

Build failed:

The external system identity may not be a SQLUsername -- that mapping is
performed at a different phase of authentication. To make this more
clear, we stop using the SQLUsername type for system identity.

Release note: None
@rafiss
Copy link
Collaborator Author

rafiss commented Sep 19, 2024

bors r+

1 similar comment
@rafiss
Copy link
Collaborator Author

rafiss commented Sep 19, 2024

bors r+

@craig
Copy link
Contributor

craig bot commented Sep 19, 2024

Already running a review

@craig craig bot merged commit 06c1f94 into cockroachdb:master Sep 19, 2024
22 of 23 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants