mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
feat: support web-auth way for wecom (#275)
Signed-off-by: sh1luo <690898835@qq.com>
This commit is contained in:
parent
e50c6cd4b5
commit
edf621f4d5
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@ -31,6 +31,7 @@ jobs:
|
||||
release:
|
||||
name: Release
|
||||
runs-on: ubuntu-latest
|
||||
if: github.repository == 'casbin/casdoor' && github.event_name == 'push'
|
||||
needs: [ frontend, backend ]
|
||||
steps:
|
||||
- name: Checkout
|
||||
|
@ -29,6 +29,7 @@ type Provider struct {
|
||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||
Category string `xorm:"varchar(100)" json:"category"`
|
||||
Type string `xorm:"varchar(100)" json:"type"`
|
||||
Method string `xorm:"varchar(100)" json:"method"`
|
||||
ClientId string `xorm:"varchar(100)" json:"clientId"`
|
||||
ClientSecret string `xorm:"varchar(100)" json:"clientSecret"`
|
||||
|
||||
@ -57,6 +58,7 @@ func getMaskedProvider(provider *Provider) *Provider {
|
||||
DisplayName: provider.DisplayName,
|
||||
Category: provider.Category,
|
||||
Type: provider.Type,
|
||||
Method: provider.Method,
|
||||
ClientId: provider.ClientId,
|
||||
}
|
||||
return p
|
||||
|
@ -231,6 +231,22 @@ class ProviderEditPage extends React.Component {
|
||||
</Select>
|
||||
</Col>
|
||||
</Row>
|
||||
{this.state.provider.type === "WeCom" ? (
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={2}>
|
||||
{Setting.getLabel(i18next.t("provider:Method"), i18next.t("provider:Method - Tooltip"))} :
|
||||
</Col>
|
||||
<Col span={22} >
|
||||
<Select virtual={false} style={{width: '100%'}} value={this.state.provider.method} onChange={value => {
|
||||
this.updateProviderField('method', value);
|
||||
}}>
|
||||
{
|
||||
[{name: "Normal"}, {name: "Silent"}].map((method, index) => <Option key={index} value={method.name}>{method.name}</Option>)
|
||||
}
|
||||
</Select>
|
||||
</Col>
|
||||
</Row>
|
||||
) : null}
|
||||
<Row style={{marginTop: '20px'}} >
|
||||
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||
{this.getClientIdLabel()}
|
||||
|
@ -51,6 +51,7 @@ class ProviderListPage extends React.Component {
|
||||
displayName: `New Provider - ${this.state.providers.length}`,
|
||||
category: "OAuth",
|
||||
type: "GitHub",
|
||||
method: "Normal",
|
||||
clientId: "",
|
||||
clientSecret: "",
|
||||
enableSignUp: true,
|
||||
|
@ -51,8 +51,9 @@ const LinkedInAuthScope = "r_liteprofile%20r_emailaddress";
|
||||
const LinkedInAuthUri = "https://www.linkedin.com/oauth/v2/authorization";
|
||||
const LinkedInAuthLogo = `${StaticBaseUrl}/img/social_linkedin.png`;
|
||||
|
||||
// const WeComAuthScope = "";
|
||||
const WeComSilentAuthScope = "snsapi_userinfo";
|
||||
const WeComAuthUri = "https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect";
|
||||
const WeComSilentAuthUrl = "https://open.weixin.qq.com/connect/oauth2/authorize";
|
||||
const WeComAuthLogo = `${StaticBaseUrl}/img/social_wecom.png`;
|
||||
|
||||
// const LarkAuthScope = "";
|
||||
@ -115,12 +116,18 @@ export function getAuthUrl(application, provider, method) {
|
||||
} else if (provider.type === "Gitee") {
|
||||
return `${GiteeAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${GiteeAuthScope}&response_type=code&state=${state}`;
|
||||
} else if (provider.type === "LinkedIn") {
|
||||
return `${LinkedInAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${LinkedInAuthScope}&response_type=code&state=${state}`
|
||||
return `${LinkedInAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${LinkedInAuthScope}&response_type=code&state=${state}`;
|
||||
} else if (provider.type === "WeCom") {
|
||||
return `${WeComAuthUri}?appid=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&usertype=member`
|
||||
if (provider.method === "Silent") {
|
||||
return `${WeComSilentAuthUrl}?appid=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&scope=${WeComSilentAuthScope}&response_type=code#wechat_redirect`;
|
||||
} else if (provider.method === "Normal") {
|
||||
return `${WeComAuthUri}?appid=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&usertype=member`;
|
||||
} else {
|
||||
return `https://error:not-supported-provider-method:${provider.method}`;
|
||||
}
|
||||
} else if (provider.type === "Lark") {
|
||||
return `${LarkAuthUri}?app_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}`
|
||||
return `${LarkAuthUri}?app_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}`;
|
||||
} else if (provider.type === "GitLab") {
|
||||
return `${GitLabAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${GitLabAuthScope}`
|
||||
return `${GitLabAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${GitLabAuthScope}`;
|
||||
}
|
||||
}
|
||||
|
@ -171,6 +171,8 @@
|
||||
"Category - Tooltip": "Unique string-style identifier",
|
||||
"Type": "Type",
|
||||
"Type - Tooltip": "Unique string-style identifier",
|
||||
"Method": "Method",
|
||||
"Method - Tooltip": "Login behaviors, QR code or silent authorization",
|
||||
"Client ID": "Client ID",
|
||||
"Client ID - Tooltip": "Unique string-style identifier",
|
||||
"Client secret": "Client secret",
|
||||
|
Loading…
x
Reference in New Issue
Block a user