diff --git a/api/login.go b/api/login.go index 2477adfbe..95c6aefda 100644 --- a/api/login.go +++ b/api/login.go @@ -322,7 +322,7 @@ func getOidcProvider(id string, ctx context.Context, redirectPath string) (*oidc } oidcProvider := config.NewProvider(ctx) var err error - if len(provider.AutoDiscovery) > 0 { + if provider.AutoDiscovery != "" { oidcProvider, err = oidc.NewProvider(ctx, provider.AutoDiscovery) if err != nil { return nil, nil, err @@ -344,20 +344,24 @@ func getOidcProvider(id string, ctx context.Context, redirectPath string) (*oidc } if redirectPath != "" { - if !strings.HasPrefix(redirectPath, "/") { - redirectPath = "/" + redirectPath - } + //if !strings.HasPrefix(redirectPath, "/") { + // redirectPath = "/" + redirectPath + //} - providerUrl, err := url.Parse(provider.RedirectURL) + redirectPath = strings.TrimRight(redirectPath, "/") - if err != nil { - return nil, nil, err + providerUrl, err2 := url.Parse(provider.RedirectURL) + + if err2 != nil { + return nil, nil, err2 } - if redirectPath == providerUrl.Path { + providerPath := strings.TrimRight(providerUrl.Path, "/") + + if redirectPath == providerPath { redirectPath = "" - } else if strings.HasPrefix(redirectPath, providerUrl.Path+"/") { - redirectPath = redirectPath[len(providerUrl.Path):] + } else if strings.HasPrefix(redirectPath, providerPath+"/") { + redirectPath = redirectPath[len(providerPath):] } }