Skip to content

feat: add auth provider sign-in to rancher login - #823

Open
wb-003153 wants to merge 1 commit into
rancher:mainfrom
wb-003153:feat/login-sso
Open

wb-003153 wants to merge 1 commit into
rancher:mainfrom
wb-003153:feat/login-sso

Conversation

@wb-003153

Copy link
Copy Markdown

Description

rancher login only accepts an API token (--token). This adds signing in with one of the server's auth providers instead, reusing the login flows the kubectl credential plugin (rancher token / rancher auth get-token, #698) already has.

rancher login https://rancher.example.com --auth-provider keyCloakProvider
  • SAML providers open the Rancher login page in the browser. OAuth providers use the device code flow, or --auth-flow authcode ([Token]: Add OAuth auth code flow for easier authentication #530, Azure AD in Implement authorization code flow for AzureAD #550). Other providers prompt for a username and password.
  • New flags: --auth-provider, --auth-flow, --skip-browser (print the login URL instead of opening a browser). --auth-provider takes a provider name or type, as in Try and find the correct provider by name rather than type. #743. Without it, the CLI asks which provider to use if the server has more than one.
  • --token works as before. Combining it with the new flags is an error.
  • Token expiry: the expiry Rancher returns is stored in cli2.json (tokenExpiresAt). Once it has passed, commands tell the user to run rancher login again instead of failing with an auth error. Tokens given with --token have no stored expiry and aren't checked.
  • The README Quickstart describes the new sign-in.

Testing

  • Unit tests in cmd/login_test.go and config/config_test.go.
  • go build ./... and go test pass.
  • Tested manually against Rancher v2.15.3 with an SSO auth provider: rancher login without --token signed in through the browser, saved the token and its expiry, and later commands used it.

@wb-003153
wb-003153 requested a review from a team as a code owner November 17, 2026 20:36
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.

1 participant