Skip to content

Commit

Permalink
fix: oauth path building (kubeshop#3991)
Browse files Browse the repository at this point in the history
* fix: oauth path building

* fix paths

* replace path.Join with url.JoinPath
  • Loading branch information
mathnogueira authored Aug 28, 2024
1 parent 1651afc commit 0002614
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
1 change: 0 additions & 1 deletion cli/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@ type Config struct {

func (c Config) OAuthEndpoint() string {
return fmt.Sprintf("%s%s", c.URL(), c.Path())

}

func (c Config) URL() string {
Expand Down
1 change: 1 addition & 0 deletions cli/config/configurator.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,7 @@ func (c Configurator) getServerURL(prev *Config) (string, error) {
}

func (c Configurator) createConfig(serverURL string) (Config, error) {
serverURL = strings.TrimSuffix(serverURL, "/")
scheme, endpoint, path, err := ParseServerURL(serverURL)
if err != nil {
return Config{}, err
Expand Down
6 changes: 5 additions & 1 deletion cli/pkg/oauth/oauth.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"io"
"net"
"net/http"
neturl "net/url"
"sync"

"github.com/kubeshop/tracetest/cli/ui"
Expand Down Expand Up @@ -58,7 +59,10 @@ func (s *OAuthServer) GetAuthJWT() error {
return fmt.Errorf("failed to start oauth server: %w", err)
}

loginUrl := fmt.Sprintf("%soauth?callback=%s", s.frontendEndpoint, url)
loginUrl, err := neturl.JoinPath(s.frontendEndpoint, fmt.Sprintf("oauth?callback=%s", url))
if err != nil {
return fmt.Errorf("could not build path: %w", err)
}

ui := ui.DefaultUI
err = ui.OpenBrowser(loginUrl)
Expand Down

0 comments on commit 0002614

Please sign in to comment.