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