Skip to content

Commit

Permalink
Merge pull request thomiceli#21 from josefandersson/oath-respect-exte…
Browse files Browse the repository at this point in the history
…rnal-url-config

Respect ExternalUrl for OAuth
  • Loading branch information
thomiceli committed May 1, 2023
2 parents 6854de0 + f8081b3 commit e0e7eb1
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions internal/web/auth.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,23 +231,29 @@ func oauth(ctx echo.Context) error {
}

giteaUrl := trimGiteaUrl()
httpDomain := httpProtocol + "://" + ctx.Request().Host

var opengistUrl string
if config.C.ExternalUrl != "" {
opengistUrl = config.C.ExternalUrl
} else {
opengistUrl = httpProtocol + "://" + ctx.Request().Host
}

switch provider {
case "github":
goth.UseProviders(
github.New(
config.C.GithubClientKey,
config.C.GithubSecret,
httpDomain+"/oauth/github/callback"),
opengistUrl+"/oauth/github/callback"),
)

case "gitea":
goth.UseProviders(
gitea.NewCustomisedURL(
config.C.GiteaClientKey,
config.C.GiteaSecret,
httpDomain+"/oauth/gitea/callback",
opengistUrl+"/oauth/gitea/callback",
giteaUrl+"/login/oauth/authorize",
giteaUrl+"/login/oauth/access_token",
giteaUrl+"/api/v1/user"),
Expand Down

0 comments on commit e0e7eb1

Please sign in to comment.