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

fix: oauth path building #3991

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
3 changes: 2 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"
"path"
"sync"

"github.com/kubeshop/tracetest/cli/ui"
Expand Down Expand Up @@ -58,7 +59,7 @@ 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 := path.Join(s.frontendEndpoint, fmt.Sprintf("oauth?callback=%s", url))
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
loginUrl := path.Join(s.frontendEndpoint, fmt.Sprintf("oauth?callback=%s", url))
loginUrl := url.JoinPath(s.frontendEndpoint, fmt.Sprintf("oauth?callback=%s", url))

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I had to create an alias for url as there is already an url var in this scope.

neturl net/url


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