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

Respect ExternalUrl for OAuth #21

Merged
Merged
Changes from all 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
Respect ExternalUrl for oauth
  • Loading branch information
josefandersson committed Apr 30, 2023
commit 5040a2fe3c89c4adb8f0fe173764c59785d903ad
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 + ":https://" + ctx.Request().Host

var opengistUrl string
if config.C.ExternalUrl != "" {
opengistUrl = config.C.ExternalUrl
} else {
opengistUrl = httpProtocol + ":https://" + 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