mirror of
https://github.com/thomiceli/opengist.git
synced 2025-01-14 20:02:42 +00:00
40 lines
715 B
Go
40 lines
715 B
Go
|
package oauth
|
||
|
|
||
|
import (
|
||
|
"github.com/markbates/goth"
|
||
|
"github.com/markbates/goth/providers/github"
|
||
|
"github.com/thomiceli/opengist/internal/config"
|
||
|
"github.com/thomiceli/opengist/internal/db"
|
||
|
)
|
||
|
|
||
|
type GitHubProvider struct {
|
||
|
Provider
|
||
|
URL string
|
||
|
}
|
||
|
|
||
|
func (p *GitHubProvider) RegisterProvider() error {
|
||
|
goth.UseProviders(
|
||
|
github.New(
|
||
|
config.C.GithubClientKey,
|
||
|
config.C.GithubSecret,
|
||
|
urlJoin(p.URL, "/oauth/github/callback"),
|
||
|
),
|
||
|
)
|
||
|
|
||
|
return nil
|
||
|
}
|
||
|
|
||
|
func (p *GitHubProvider) SSHKeysURL(user *db.User) string {
|
||
|
|
||
|
}
|
||
|
|
||
|
func (p *GitHubProvider) GetProviderUserID(user *db.User) bool {
|
||
|
return user.GithubID != ""
|
||
|
}
|
||
|
|
||
|
func NewGitHubProvider(url string) *GitHubProvider {
|
||
|
return &GitHubProvider{
|
||
|
URL: url,
|
||
|
}
|
||
|
}
|