Skip to content

Commit

Permalink
fix: CLI login with custom auth URL
Browse files Browse the repository at this point in the history
  • Loading branch information
rangoo94 committed Nov 13, 2024
1 parent a2b13f3 commit 2dcea4d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 1 deletion.
5 changes: 4 additions & 1 deletion cmd/kubectl-testkube/commands/common/client.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,10 @@ func GetClient(cmd *cobra.Command) (client.Client, string, error) {

if cfg.CloudContext.ApiKey != "" && cfg.CloudContext.RefreshToken != "" {
var refreshToken string
authURI := fmt.Sprintf("%s/idp", cfg.CloudContext.ApiUri)
authURI := cfg.CloudContext.AuthUri
if cfg.CloudContext.AuthUri == "" {
authURI = fmt.Sprintf("%s/idp", cfg.CloudContext.ApiUri)
}
token, refreshToken, err = cloudlogin.CheckAndRefreshToken(context.Background(), authURI, cfg.CloudContext.ApiKey, cfg.CloudContext.RefreshToken)
if err != nil {
// Error: failed refreshing, go thru login flow
Expand Down
7 changes: 7 additions & 0 deletions cmd/kubectl-testkube/commands/common/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -311,6 +311,9 @@ func PopulateLoginDataToContext(orgID, envID, token, refreshToken, dockerContain
if options.Master.URIs.Api != "" {
cfg.CloudContext.ApiUri = options.Master.URIs.Api
}
if options.Master.URIs.Auth != "" {
cfg.CloudContext.AuthUri = options.Master.URIs.Auth
}
cfg.ContextType = config.ContextTypeCloud
cfg.CloudContext.OrganizationId = orgID
cfg.CloudContext.EnvironmentId = envID
Expand Down Expand Up @@ -349,6 +352,10 @@ func PopulateAgentDataToContext(options HelmOptions, cfg config.Data) error {
cfg.CloudContext.ApiUri = options.Master.URIs.Api
updated = true
}
if options.Master.URIs.Auth != "" {
cfg.CloudContext.AuthUri = options.Master.URIs.Auth
updated = true
}
if options.Master.IdToken != "" {
cfg.CloudContext.ApiKey = options.Master.IdToken
updated = true
Expand Down
1 change: 1 addition & 0 deletions cmd/kubectl-testkube/config/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ type CloudContext struct {
AgentUri string `json:"agentUri,omitempty"`
RootDomain string `json:"rootDomain,omitempty"`
UiUri string `json:"uiUri,omitempty"`
AuthUri string `json:"authUri,omitempty"`
TokenType string `json:"tokenType,omitempty"`
DockerContainerName string `json:"dockerContainerName,omitempty"`
CustomAuth bool `json:"customConnector,omitempty"`
Expand Down

0 comments on commit 2dcea4d

Please sign in to comment.