mirror of
https://github.com/thomiceli/opengist.git
synced 2025-01-14 03:42:40 +00:00
33 lines
677 B
Go
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,
|
|
}
|
|
}
|