Skip to content

Commit

Permalink
rpk: take into account auth kind to clear profiles
Browse files Browse the repository at this point in the history
If we have profile A from auth SSO, we cannot keep profile A if we
subsequently log in with client credentials. Even though the
organizations are the same, the auth is different, and we need a new
profile tied to the new auth.
  • Loading branch information
twmb committed Mar 14, 2024
1 parent 9d55535 commit f470087
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions src/go/rpk/pkg/oauth/load.go
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ func LoadFlow(ctx context.Context, fs afero.Fs, cfg *config.Config, cl Client, n
if orgErr != nil {
return nil, authVir, false, false, orgErr
}
if org.ID != pAuthAct.OrgID {
if org.ID != pAuthAct.OrgID || pAuthAct.Kind != authKind {
clearedProfile = true
yAct.CurrentProfile = ""
yVir.CurrentProfile = ""
Expand All @@ -112,12 +112,8 @@ func LoadFlow(ctx context.Context, fs afero.Fs, cfg *config.Config, cl Client, n
if orgErr != nil {
return nil, authVir, false, false, orgErr
}
if org.ID != yAuthAct.OrgID {
if org.ID != yAuthAct.OrgID || yAuthAct.Kind != authKind {
yAuthVir := yVir.CurrentAuth()
// The virtual auth here *should* have the same org and kind.
if yAuthAct.OrgID != yAuthVir.OrgID || yAuthAct.Kind != yAuthVir.Kind {
panic("params invariant: virtual auth != actual auth")
}
yAct.CurrentCloudAuthOrgID = ""
yVir.CurrentCloudAuthOrgID = ""
yAct.CurrentCloudAuthKind = ""
Expand Down

0 comments on commit f470087

Please sign in to comment.