mirror of
https://github.com/thomiceli/opengist.git
synced 2025-01-14 03:42:40 +00:00
42 lines
876 B
Go
42 lines
876 B
Go
package oauth
|
|
|
|
import (
|
|
"github.com/markbates/goth"
|
|
"github.com/markbates/goth/providers/gitlab"
|
|
"github.com/thomiceli/opengist/internal/config"
|
|
"github.com/thomiceli/opengist/internal/db"
|
|
)
|
|
|
|
type GitLabProvider struct {
|
|
Provider
|
|
URL string
|
|
}
|
|
|
|
func (p *GitLabProvider) RegisterProvider() error {
|
|
goth.UseProviders(
|
|
gitlab.NewCustomisedURL(
|
|
config.C.GitlabClientKey,
|
|
config.C.GitlabSecret,
|
|
urlJoin(p.URL, "/oauth/gitlab/callback"),
|
|
urlJoin(config.C.GitlabUrl, "/oauth/authorize"),
|
|
urlJoin(config.C.GitlabUrl, "/oauth/token"),
|
|
urlJoin(config.C.GitlabUrl, "/api/v4/user"),
|
|
),
|
|
)
|
|
|
|
return nil
|
|
}
|
|
|
|
func (p *GitLabProvider) SSHKeysURL(user *db.User) string {
|
|
|
|
}
|
|
|
|
func (p *GitLabProvider) GetProviderUserID(user *db.User) bool {
|
|
return user.GitlabID != ""
|
|
}
|
|
|
|
func NewGitLabProvider(url string) *GitLabProvider {
|
|
return &GitLabProvider{
|
|
URL: url,
|
|
}
|
|
}
|