feature: support Google Oauth2.0

This commit is contained in:
Qiu Jian
2021-07-08 02:27:05 +08:00
parent 119c5b155d
commit f08ea8b2c8
5 changed files with 54 additions and 0 deletions
+1
View File
@@ -95,6 +95,7 @@ const (
IdpTemplateDex = "dex_oidc"
IdpTemplateGithub = "github_oidc"
IdpTemplateAzureOAuth2 = "azure_oidc"
IdpTemplateGoogle = "google_oidc"
IdpTemplateAlipay = "alipay_oauth2"
IdpTemplateWechat = "wechat_oauth2"
+7
View File
@@ -46,6 +46,13 @@ type SOIDCGithubConfigOptions struct {
SIdpAttributeOptions
}
type SOIDCGoogleConfigOptions struct {
ClientId string `json:"client_id"`
ClientSecret string `json:"client_secret"`
SIdpAttributeOptions
}
const (
AZURE_CLOUD_ENV_CHINA = "china"
AZURE_CLOUD_ENV_GLOBAL = "global"
+2
View File
@@ -73,6 +73,8 @@ func (self *SOIDCDriver) prepareConfig() error {
conf = DexOIDCTemplate
case api.IdpTemplateGithub:
conf = GithubOIDCTemplate
case api.IdpTemplateGoogle:
conf = GoogleOIDCTemplate
case api.IdpTemplateAzureOAuth2:
conf = AzureADTemplate
tenantId, _ := confJson.GetString("tenant_id")
+20
View File
@@ -53,6 +53,26 @@ var (
},
}
// {
// "sub": "112176790568447731603",
// "name": "Jian Qiu",
// "given_name": "Jian",
// "family_name": "Qiu",
// "picture": "https://lh3.googleusercontent.com/a/AATXAJyj32UmKhmwI38ljm8xI53LX4Lw3w5wYxKsj4JS\u003ds96-c",
// "email": "swordqiu@gmail.com",
// "email_verified": true,
// "locale": "zh-CN"
// }
GoogleOIDCTemplate = api.SOIDCIdpConfigOptions{
Endpoint: "https://accounts.google.com",
SIdpAttributeOptions: api.SIdpAttributeOptions{
UserIdAttribute: "sub",
UserNameAttribute: "email",
UserEmailAttribute: "email",
UserDisplaynameAttribtue: "name",
},
}
AzureADTemplate = api.SOIDCIdpConfigOptions{
Scopes: []string{
"openid",