opengist/internal/auth/oauth/gitea.go
Thomas Miceli c2899ef41b wip
2025-01-11 20:17:01 +01:00

33 lines
677 B
Go

package oauth
import (
"github.com/markbates/goth"
"github.com/markbates/goth/providers/gitea"
"github.com/thomiceli/opengist/internal/config"
)
type GiteaProvider struct {
Provider
URL string
}
func (p *GiteaProvider) RegisterProvider() error {
goth.UseProviders(
gitea.NewCustomisedURL(
config.C.GiteaClientKey,
config.C.GiteaSecret,
urlJoin(p.URL, "/oauth/gitea/callback"),
urlJoin(config.C.GiteaUrl, "/login/oauth/authorize"),
urlJoin(config.C.GiteaUrl, "/login/oauth/access_token"),
urlJoin(config.C.GiteaUrl, "/api/v1/user"),
),
)
return nil
}
func NewGiteaProvider(url string) *GiteaProvider {
return &GiteaProvider{
URL: url,
}
}