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

[CLI-2816] On-prem OAuth SSO support #2652

Merged
merged 38 commits into from
May 29, 2024
Merged

[CLI-2816] On-prem OAuth SSO support #2652

merged 38 commits into from
May 29, 2024

Conversation

sgagniere
Copy link
Member

@sgagniere sgagniere commented Feb 24, 2024

Release Notes

Breaking Changes

  • PLACEHOLDER

New Features

  • Support on-premises SSO authentication with confluent login
  • Add a new on-premises confluent iam user describe to display username and authentication token

Bug Fixes

  • PLACEHOLDER

Checklist

  • Leave this box unchecked if features are not yet available in production

What

Add support for on-premises SSO authentication when oidc.login.device.1.enabled is enabled.

When both SSO and LDAP are enabled (which is possible for on-prem), we should prefer SSO. So the current order of precedence is prompt flag > environment variables (SSO > LDAP) > LDAP (keychain > config > netrc) > SSO > LDAP (prompt).

References

Test & Review

Manual testing

internal/login/command.go Outdated Show resolved Hide resolved
internal/login/command.go Show resolved Hide resolved
internal/login/command.go Show resolved Hide resolved
internal/login/command.go Outdated Show resolved Hide resolved
pkg/auth/auth.go Outdated Show resolved Hide resolved
pkg/auth/auth.go Outdated Show resolved Hide resolved
pkg/auth/auth.go Outdated Show resolved Hide resolved
pkg/auth/login_credentials_manager.go Outdated Show resolved Hide resolved
pkg/auth/login_credentials_manager.go Outdated Show resolved Hide resolved
pkg/auth/login_credentials_manager.go Show resolved Hide resolved
@sgagniere sgagniere changed the title Cli 2816 [CLI-2816] On-prem OAuth SSO support Feb 27, 2024
@brianstrauch
Copy link
Member

brianstrauch commented Feb 27, 2024

Support on-premises SSO authentication with confluent login

Would it make sense to say confluent login --url <sso-enabled-mds-url> in this release note? (Not sure on the specific terminology)

internal/command.go Outdated Show resolved Hide resolved
internal/flink/command_shell.go Outdated Show resolved Hide resolved
pkg/auth/auth.go Outdated Show resolved Hide resolved
pkg/auth/auth.go Show resolved Hide resolved
pkg/jwt/token_validator.go Outdated Show resolved Hide resolved
internal/login/command.go Show resolved Hide resolved
internal/login/command.go Outdated Show resolved Hide resolved
internal/login/command.go Outdated Show resolved Hide resolved
pkg/auth/auth.go Outdated Show resolved Hide resolved
@@ -141,13 +145,74 @@ func (a *AuthTokenHandlerImpl) refreshCCloudSSOToken(client *ccloudv1.Client, re
return res.GetToken(), refreshToken, err
}

func (a *AuthTokenHandlerImpl) GetConfluentToken(mdsClient *mdsv1.APIClient, credentials *Credentials) (string, error) {
func (a *AuthTokenHandlerImpl) GetConfluentToken(mdsClient *mdsv1.APIClient, credentials *Credentials, noBrowser bool) (string, string, error) {
ctx := utils.GetContext()
Copy link
Member

Choose a reason for hiding this comment

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

Didn't know we had this function... maybe we should try to deprecate/remove it? The standard approach to getting the context is from the (un)authenticated command struct

Copy link
Member Author

Choose a reason for hiding this comment

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

This isn't a config.Context, but a context.Context.

Copy link
Member

Choose a reason for hiding this comment

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

Oh, meaning from the stdlib "context" package?

Copy link
Member

Choose a reason for hiding this comment

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

Huh, I'm looking at the implementation of this. Why do we need to log DNS/TLS information here?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm. I'm not sure. Maybe we can replace both calls to this w/ background context and remove it like you suggested at the start.

pkg/auth/auth_token_handler.go Outdated Show resolved Hide resolved
pkg/auth/auth_token_handler.go Outdated Show resolved Hide resolved
pkg/auth/login_credentials_manager.go Show resolved Hide resolved
pkg/auth/login_credentials_manager.go Show resolved Hide resolved
pkg/auth/login_credentials_manager.go Outdated Show resolved Hide resolved
Comment on lines +80 to +81
GetOnPremSsoCredentials(url, caCertPath string, unsafeTrace bool) func() (*Credentials, error)
GetOnPremSsoCredentialsFromConfig(*config.Config, bool) func() (*Credentials, error)
Copy link
Member

Choose a reason for hiding this comment

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

I think these functions should be able to be combined into one, right?

Copy link
Member Author

Choose a reason for hiding this comment

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

Probably, yeah, I'll give it a try.

Copy link
Member Author

Choose a reason for hiding this comment

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

Not sure how to do this neatly, actually.

The issue is that when you first do confluent login --url ..., the context is empty so you need to pass in the url and ca-cert-path values from the flag. But afterwards, when using the refresh token, I need to use the url and ca-cert-path from the Context (because some on-prem commands don't support those flags).

So a combined function needs to pass in url, ca-cert-path, and config/context (which I also need for auth and refresh token in addition to url and ca-cert-path) to account for both cases.

go.mod Outdated Show resolved Hide resolved
@sgagniere sgagniere marked this pull request as ready for review May 29, 2024 00:59
@sgagniere sgagniere requested a review from a team as a code owner May 29, 2024 00:59
@sgagniere sgagniere merged commit 0d07e42 into main May 29, 2024
2 checks passed
@sgagniere sgagniere deleted the cli-2816 branch May 29, 2024 18:49
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.

None yet

2 participants