Skip to content

Commit

Permalink
fix(oauth): remove extra slash
Browse files Browse the repository at this point in the history
  • Loading branch information
fiftin committed Mar 27, 2024
1 parent d33d752 commit e26b9fa
Showing 1 changed file with 14 additions and 10 deletions.
24 changes: 14 additions & 10 deletions api/login.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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):]
}
}

Expand Down

0 comments on commit e26b9fa

Please sign in to comment.