feat: add lark provider (#264)

Signed-off-by: sh1luo <690898835@qq.com>
This commit is contained in:
sh1luo
2021-08-14 16:00:38 +08:00
committed by GitHub
parent 004282f970
commit c05b27c38f
7 changed files with 265 additions and 2 deletions

View File

@ -76,6 +76,7 @@ class ProviderEditPage extends React.Component {
{id: 'Gitee', name: 'Gitee'},
{id: 'LinkedIn', name: 'LinkedIn'},
{id: 'WeCom', name: 'WeCom'},
{id: 'Lark', name: 'Lark'},
]
);
} else if (provider.category === "Email") {

View File

@ -0,0 +1,32 @@
// Copyright 2021 The casbin Authors. All Rights Reserved.
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
import {createButton} from "react-social-login-buttons";
import {StaticBaseUrl} from "../Setting";
function Icon({ width = 24, height = 24, color }) {
return <img src={`${StaticBaseUrl}/buttons/lark.svg`} alt="Sign in with Lark" style={{width: 24, height: 24}} />;
}
const config = {
text: "Sign in with Lark",
icon: Icon,
iconFormat: name => `fa fa-${name}`,
style: {background: "#ffffff", color: "#000000"},
activeStyle: {background: "#ededee"},
};
const LarkLoginButton = createButton(config);
export default LarkLoginButton;

View File

@ -31,6 +31,7 @@ import WeiboLoginButton from "./WeiboLoginButton";
import i18next from "i18next";
import LinkedInLoginButton from "./LinkedInLoginButton";
import WeComLoginButton from "./WeComLoginButton";
import LarkLoginButton from "./LarkLoginButton";
class LoginPage extends React.Component {
constructor(props) {
@ -167,6 +168,8 @@ class LoginPage extends React.Component {
return <LinkedInLoginButton text={text} align={"center"} />
} else if (type === "WeCom") {
return <WeComLoginButton text={text} align={"center"} />
} else if (type === "Lark") {
return <LarkLoginButton text={text} align={"center"} />
}
return text;

View File

@ -55,6 +55,10 @@ const LinkedInAuthLogo = `${StaticBaseUrl}/img/social_linkedin.png`;
const WeComAuthUri = "https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect";
const WeComAuthLogo = `${StaticBaseUrl}/img/social_wecom.png`;
// const WeComAuthScope = "";
const LarkAuthUri = "https://open.feishu.cn/open-apis/authen/v1/index";
const LarkAuthLogo = `${StaticBaseUrl}/img/social_lark.png`;
export function getAuthLogo(provider) {
if (provider.type === "Google") {
return GoogleAuthLogo;
@ -74,8 +78,10 @@ export function getAuthLogo(provider) {
return GiteeAuthLogo;
} else if (provider.type === "LinkedIn") {
return LinkedInAuthLogo;
} else if (provider.type === "WeCom") {
} else if (provider.type === "WeCom") {
return WeComAuthLogo;
} else if (provider.type === "Lark") {
return LarkAuthLogo;
}
}
@ -104,7 +110,9 @@ export function getAuthUrl(application, provider, method) {
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}`
} else if (provider.type === "WeCom") {
} else if (provider.type === "WeCom") {
return `${WeComAuthUri}?appid=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&usertype=member`
} else if (provider.type === "Lark") {
return `${LarkAuthUri}?app_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}`
}
}