mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-06 18:10:29 +08:00
feat: support web-auth way for wecom (#275)
Signed-off-by: sh1luo <690898835@qq.com>
This commit is contained in:
1
.github/workflows/build.yml
vendored
1
.github/workflows/build.yml
vendored
@@ -31,6 +31,7 @@ jobs:
|
|||||||
release:
|
release:
|
||||||
name: Release
|
name: Release
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
if: github.repository == 'casbin/casdoor' && github.event_name == 'push'
|
||||||
needs: [ frontend, backend ]
|
needs: [ frontend, backend ]
|
||||||
steps:
|
steps:
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
|
@@ -29,6 +29,7 @@ type Provider struct {
|
|||||||
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
DisplayName string `xorm:"varchar(100)" json:"displayName"`
|
||||||
Category string `xorm:"varchar(100)" json:"category"`
|
Category string `xorm:"varchar(100)" json:"category"`
|
||||||
Type string `xorm:"varchar(100)" json:"type"`
|
Type string `xorm:"varchar(100)" json:"type"`
|
||||||
|
Method string `xorm:"varchar(100)" json:"method"`
|
||||||
ClientId string `xorm:"varchar(100)" json:"clientId"`
|
ClientId string `xorm:"varchar(100)" json:"clientId"`
|
||||||
ClientSecret string `xorm:"varchar(100)" json:"clientSecret"`
|
ClientSecret string `xorm:"varchar(100)" json:"clientSecret"`
|
||||||
|
|
||||||
@@ -57,6 +58,7 @@ func getMaskedProvider(provider *Provider) *Provider {
|
|||||||
DisplayName: provider.DisplayName,
|
DisplayName: provider.DisplayName,
|
||||||
Category: provider.Category,
|
Category: provider.Category,
|
||||||
Type: provider.Type,
|
Type: provider.Type,
|
||||||
|
Method: provider.Method,
|
||||||
ClientId: provider.ClientId,
|
ClientId: provider.ClientId,
|
||||||
}
|
}
|
||||||
return p
|
return p
|
||||||
|
@@ -231,6 +231,22 @@ class ProviderEditPage extends React.Component {
|
|||||||
</Select>
|
</Select>
|
||||||
</Col>
|
</Col>
|
||||||
</Row>
|
</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'}} >
|
<Row style={{marginTop: '20px'}} >
|
||||||
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
|
<Col style={{marginTop: '5px'}} span={(Setting.isMobile()) ? 22 : 2}>
|
||||||
{this.getClientIdLabel()}
|
{this.getClientIdLabel()}
|
||||||
|
@@ -51,6 +51,7 @@ class ProviderListPage extends React.Component {
|
|||||||
displayName: `New Provider - ${this.state.providers.length}`,
|
displayName: `New Provider - ${this.state.providers.length}`,
|
||||||
category: "OAuth",
|
category: "OAuth",
|
||||||
type: "GitHub",
|
type: "GitHub",
|
||||||
|
method: "Normal",
|
||||||
clientId: "",
|
clientId: "",
|
||||||
clientSecret: "",
|
clientSecret: "",
|
||||||
enableSignUp: true,
|
enableSignUp: true,
|
||||||
|
@@ -51,8 +51,9 @@ const LinkedInAuthScope = "r_liteprofile%20r_emailaddress";
|
|||||||
const LinkedInAuthUri = "https://www.linkedin.com/oauth/v2/authorization";
|
const LinkedInAuthUri = "https://www.linkedin.com/oauth/v2/authorization";
|
||||||
const LinkedInAuthLogo = `${StaticBaseUrl}/img/social_linkedin.png`;
|
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 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 WeComAuthLogo = `${StaticBaseUrl}/img/social_wecom.png`;
|
||||||
|
|
||||||
// const LarkAuthScope = "";
|
// const LarkAuthScope = "";
|
||||||
@@ -115,12 +116,18 @@ export function getAuthUrl(application, provider, method) {
|
|||||||
} else if (provider.type === "Gitee") {
|
} else if (provider.type === "Gitee") {
|
||||||
return `${GiteeAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${GiteeAuthScope}&response_type=code&state=${state}`;
|
return `${GiteeAuthUri}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${GiteeAuthScope}&response_type=code&state=${state}`;
|
||||||
} else if (provider.type === "LinkedIn") {
|
} 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") {
|
} 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") {
|
} 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") {
|
} 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",
|
"Category - Tooltip": "Unique string-style identifier",
|
||||||
"Type": "Type",
|
"Type": "Type",
|
||||||
"Type - Tooltip": "Unique string-style identifier",
|
"Type - Tooltip": "Unique string-style identifier",
|
||||||
|
"Method": "Method",
|
||||||
|
"Method - Tooltip": "Login behaviors, QR code or silent authorization",
|
||||||
"Client ID": "Client ID",
|
"Client ID": "Client ID",
|
||||||
"Client ID - Tooltip": "Unique string-style identifier",
|
"Client ID - Tooltip": "Unique string-style identifier",
|
||||||
"Client secret": "Client secret",
|
"Client secret": "Client secret",
|
||||||
|
Reference in New Issue
Block a user