mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-05-06 13:48:52 +00:00
feat: 绑定 oauth2
This commit is contained in:
@@ -0,0 +1,33 @@
|
||||
package model
|
||||
|
||||
import (
|
||||
"golang.org/x/oauth2"
|
||||
)
|
||||
|
||||
type Oauth2Config struct {
|
||||
ClientID string `mapstructure:"client_id" json:"client_id,omitempty"`
|
||||
ClientSecret string `mapstructure:"client_secret" json:"client_secret,omitempty"`
|
||||
Endpoint Oauth2Endpoint `mapstructure:"endpoint" json:"endpoint,omitempty"`
|
||||
Scopes []string `mapstructure:"scopes" json:"scopes,omitempty"`
|
||||
|
||||
UserInfoURL string `mapstructure:"user_info_url" json:"user_info_url,omitempty"`
|
||||
UserIDPath string `mapstructure:"user_id_path" json:"user_id_path,omitempty"`
|
||||
}
|
||||
|
||||
type Oauth2Endpoint struct {
|
||||
AuthURL string `mapstructure:"auth_url" json:"auth_url,omitempty"`
|
||||
TokenURL string `mapstructure:"token_url" json:"token_url,omitempty"`
|
||||
}
|
||||
|
||||
func (c *Oauth2Config) Setup(redirectURL string) *oauth2.Config {
|
||||
return &oauth2.Config{
|
||||
ClientID: c.ClientID,
|
||||
ClientSecret: c.ClientSecret,
|
||||
Endpoint: oauth2.Endpoint{
|
||||
AuthURL: c.Endpoint.AuthURL,
|
||||
TokenURL: c.Endpoint.TokenURL,
|
||||
},
|
||||
RedirectURL: redirectURL,
|
||||
Scopes: c.Scopes,
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user