2022-02-13 23:39:27 +08:00
|
|
|
// Copyright 2021 The Casdoor Authors. All Rights Reserved.
|
2021-02-14 16:59:08 +08:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
|
2021-11-28 18:46:20 +08:00
|
|
|
import React from "react";
|
|
|
|
import {Tooltip} from "antd";
|
2021-03-21 13:45:55 +08:00
|
|
|
import * as Util from "./Util";
|
2022-03-19 19:43:54 +08:00
|
|
|
import * as Setting from "../Setting";
|
2021-02-14 16:59:08 +08:00
|
|
|
|
2021-10-09 22:15:43 +08:00
|
|
|
const authInfo = {
|
|
|
|
Google: {
|
|
|
|
scope: "profile+email",
|
|
|
|
endpoint: "https://accounts.google.com/signin/oauth",
|
|
|
|
},
|
|
|
|
GitHub: {
|
|
|
|
scope: "user:email+read:user",
|
|
|
|
endpoint: "https://github.com/login/oauth/authorize",
|
|
|
|
},
|
|
|
|
QQ: {
|
|
|
|
scope: "get_user_info",
|
|
|
|
endpoint: "https://graph.qq.com/oauth2.0/authorize",
|
|
|
|
},
|
|
|
|
WeChat: {
|
|
|
|
scope: "snsapi_login",
|
|
|
|
endpoint: "https://open.weixin.qq.com/connect/qrconnect",
|
2021-12-20 23:36:28 +08:00
|
|
|
mpScope: "snsapi_userinfo",
|
2022-08-06 23:54:56 +08:00
|
|
|
mpEndpoint: "https://open.weixin.qq.com/connect/oauth2/authorize",
|
2021-10-09 22:15:43 +08:00
|
|
|
},
|
2022-04-15 11:49:56 +08:00
|
|
|
WeChatMiniProgram: {
|
|
|
|
endpoint: "https://mp.weixin.qq.com/",
|
|
|
|
},
|
2021-10-09 22:15:43 +08:00
|
|
|
Facebook: {
|
|
|
|
scope: "email,public_profile",
|
|
|
|
endpoint: "https://www.facebook.com/dialog/oauth",
|
|
|
|
},
|
|
|
|
DingTalk: {
|
2022-02-10 17:14:18 +08:00
|
|
|
scope: "openid",
|
|
|
|
endpoint: "https://login.dingtalk.com/oauth2/auth",
|
2021-10-09 22:15:43 +08:00
|
|
|
},
|
|
|
|
Weibo: {
|
|
|
|
scope: "email",
|
|
|
|
endpoint: "https://api.weibo.com/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Gitee: {
|
|
|
|
scope: "user_info%20emails",
|
|
|
|
endpoint: "https://gitee.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
LinkedIn: {
|
|
|
|
scope: "r_liteprofile%20r_emailaddress",
|
|
|
|
endpoint: "https://www.linkedin.com/oauth/v2/authorization",
|
|
|
|
},
|
|
|
|
WeCom: {
|
|
|
|
scope: "snsapi_userinfo",
|
|
|
|
endpoint: "https://open.work.weixin.qq.com/wwopen/sso/3rd_qrConnect",
|
|
|
|
silentEndpoint: "https://open.weixin.qq.com/connect/oauth2/authorize",
|
2022-01-28 23:57:54 +08:00
|
|
|
internalEndpoint: "https://open.work.weixin.qq.com/wwopen/sso/qrConnect",
|
2021-10-09 22:15:43 +08:00
|
|
|
},
|
|
|
|
Lark: {
|
|
|
|
// scope: "email",
|
|
|
|
endpoint: "https://open.feishu.cn/open-apis/authen/v1/index",
|
|
|
|
},
|
|
|
|
GitLab: {
|
|
|
|
scope: "read_user+profile",
|
|
|
|
endpoint: "https://gitlab.com/oauth/authorize",
|
|
|
|
},
|
2023-07-30 17:31:36 +08:00
|
|
|
ADFS: {
|
2022-02-20 15:01:48 +08:00
|
|
|
scope: "openid",
|
|
|
|
endpoint: "http://example.com",
|
|
|
|
},
|
2022-01-22 19:36:44 +08:00
|
|
|
Baidu: {
|
|
|
|
scope: "basic",
|
|
|
|
endpoint: "http://openapi.baidu.com/oauth/2.0/authorize",
|
|
|
|
},
|
2022-04-02 22:37:13 +08:00
|
|
|
Alipay: {
|
|
|
|
scope: "basic",
|
|
|
|
endpoint: "https://openauth.alipay.com/oauth2/publicAppAuthorize.htm",
|
|
|
|
},
|
2022-03-18 18:28:46 +08:00
|
|
|
Casdoor: {
|
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "http://example.com",
|
|
|
|
},
|
2022-02-05 21:54:38 +08:00
|
|
|
Infoflow: {
|
|
|
|
endpoint: "https://xpc.im.baidu.com/oauth2/authorize",
|
|
|
|
},
|
2021-12-10 00:55:27 +08:00
|
|
|
Apple: {
|
|
|
|
scope: "name%20email",
|
|
|
|
endpoint: "https://appleid.apple.com/auth/authorize",
|
|
|
|
},
|
|
|
|
AzureAD: {
|
2022-07-04 16:40:23 +08:00
|
|
|
scope: "user.read",
|
|
|
|
endpoint: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
2021-12-10 00:55:27 +08:00
|
|
|
},
|
|
|
|
Slack: {
|
|
|
|
scope: "users:read",
|
|
|
|
endpoint: "https://slack.com/oauth/authorize",
|
|
|
|
},
|
2022-02-16 19:57:46 +08:00
|
|
|
Steam: {
|
|
|
|
endpoint: "https://steamcommunity.com/openid/login",
|
|
|
|
},
|
2022-05-01 18:31:42 +08:00
|
|
|
Okta: {
|
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "http://example.com",
|
|
|
|
},
|
2022-05-15 20:59:21 +08:00
|
|
|
Douyin: {
|
|
|
|
scope: "user_info",
|
|
|
|
endpoint: "https://open.douyin.com/platform/oauth/connect",
|
|
|
|
},
|
2022-04-16 17:17:45 +08:00
|
|
|
Custom: {
|
|
|
|
endpoint: "https://example.com/",
|
|
|
|
},
|
2022-05-12 10:07:52 +08:00
|
|
|
Bilibili: {
|
2022-08-06 23:54:56 +08:00
|
|
|
endpoint: "https://passport.bilibili.com/register/pc_oauth2.html",
|
|
|
|
},
|
2022-12-21 02:25:58 +08:00
|
|
|
Line: {
|
|
|
|
scope: "profile%20openid%20email",
|
|
|
|
endpoint: "https://access.line.me/oauth2/v2.1/authorize",
|
|
|
|
},
|
2023-02-04 12:20:18 +08:00
|
|
|
Amazon: {
|
|
|
|
scope: "profile",
|
|
|
|
endpoint: "https://www.amazon.com/ap/oa",
|
|
|
|
},
|
|
|
|
Auth0: {
|
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "http://auth0.com/authorize",
|
|
|
|
},
|
|
|
|
BattleNet: {
|
|
|
|
scope: "openid",
|
|
|
|
endpoint: "https://oauth.battlenet.com.cn/authorize",
|
|
|
|
},
|
|
|
|
Bitbucket: {
|
|
|
|
scope: "account",
|
|
|
|
endpoint: "https://bitbucket.org/site/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Box: {
|
|
|
|
scope: "root_readwrite",
|
|
|
|
endpoint: "https://account.box.com/api/oauth2/authorize",
|
|
|
|
},
|
|
|
|
CloudFoundry: {
|
|
|
|
scope: "cloud_controller.read",
|
|
|
|
endpoint: "https://login.cloudfoundry.org/oauth/authorize",
|
|
|
|
},
|
|
|
|
Dailymotion: {
|
|
|
|
scope: "userinfo",
|
|
|
|
endpoint: "https://api.dailymotion.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
Deezer: {
|
|
|
|
scope: "basic_access",
|
|
|
|
endpoint: "https://connect.deezer.com/oauth/auth.php",
|
|
|
|
},
|
|
|
|
DigitalOcean: {
|
|
|
|
scope: "read",
|
|
|
|
endpoint: "https://cloud.digitalocean.com/v1/oauth/authorize",
|
|
|
|
},
|
|
|
|
Discord: {
|
|
|
|
scope: "identify%20email",
|
|
|
|
endpoint: "https://discord.com/api/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Dropbox: {
|
|
|
|
scope: "account_info.read",
|
|
|
|
endpoint: "https://www.dropbox.com/oauth2/authorize",
|
|
|
|
},
|
|
|
|
EveOnline: {
|
|
|
|
scope: "publicData",
|
|
|
|
endpoint: "https://login.eveonline.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
Fitbit: {
|
|
|
|
scope: "activity%20heartrate%20location%20nutrition%20profile%20settings%20sleep%20social%20weight",
|
|
|
|
endpoint: "https://www.fitbit.com/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Gitea: {
|
|
|
|
scope: "user:email",
|
|
|
|
endpoint: "https://gitea.com/login/oauth/authorize",
|
|
|
|
},
|
|
|
|
Heroku: {
|
|
|
|
scope: "global",
|
|
|
|
endpoint: "https://id.heroku.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
InfluxCloud: {
|
|
|
|
scope: "read:org",
|
|
|
|
endpoint: "https://cloud2.influxdata.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
Instagram: {
|
|
|
|
scope: "user_profile",
|
|
|
|
endpoint: "https://api.instagram.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
Intercom: {
|
|
|
|
scope: "user.read",
|
|
|
|
endpoint: "https://app.intercom.com/oauth",
|
|
|
|
},
|
|
|
|
Kakao: {
|
|
|
|
scope: "account_email",
|
|
|
|
endpoint: "https://kauth.kakao.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
Lastfm: {
|
|
|
|
scope: "user_read",
|
|
|
|
endpoint: "https://www.last.fm/api/auth",
|
|
|
|
},
|
|
|
|
Mailru: {
|
|
|
|
scope: "userinfo",
|
|
|
|
endpoint: "https://oauth.mail.ru/login",
|
|
|
|
},
|
|
|
|
Meetup: {
|
|
|
|
scope: "basic",
|
|
|
|
endpoint: "https://secure.meetup.com/oauth2/authorize",
|
|
|
|
},
|
|
|
|
MicrosoftOnline: {
|
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "https://login.microsoftonline.com/common/oauth2/v2.0/authorize",
|
|
|
|
},
|
|
|
|
Naver: {
|
|
|
|
scope: "profile",
|
|
|
|
endpoint: "https://nid.naver.com/oauth2.0/authorize",
|
|
|
|
},
|
|
|
|
Nextcloud: {
|
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "https://cloud.example.org/apps/oauth2/authorize",
|
|
|
|
},
|
|
|
|
OneDrive: {
|
|
|
|
scope: "offline_access%20onedrive.readonly",
|
|
|
|
endpoint: "https://login.live.com/oauth20_authorize.srf",
|
|
|
|
},
|
|
|
|
Oura: {
|
|
|
|
scope: "personal",
|
|
|
|
endpoint: "https://cloud.ouraring.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
Patreon: {
|
|
|
|
scope: "identity",
|
|
|
|
endpoint: "https://www.patreon.com/oauth2/authorize",
|
|
|
|
},
|
2023-03-18 18:54:05 +08:00
|
|
|
PayPal: {
|
2023-02-04 12:20:18 +08:00
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "https://www.sandbox.paypal.com/connect",
|
|
|
|
},
|
|
|
|
SalesForce: {
|
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "https://login.salesforce.com/services/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Shopify: {
|
|
|
|
scope: "read_products",
|
|
|
|
endpoint: "https://myshopify.com/admin/oauth/authorize",
|
|
|
|
},
|
|
|
|
Soundcloud: {
|
|
|
|
scope: "non-expiring",
|
|
|
|
endpoint: "https://api.soundcloud.com/connect",
|
|
|
|
},
|
|
|
|
Spotify: {
|
|
|
|
scope: "user-read-email",
|
|
|
|
endpoint: "https://accounts.spotify.com/authorize",
|
|
|
|
},
|
|
|
|
Strava: {
|
|
|
|
scope: "read",
|
|
|
|
endpoint: "https://www.strava.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
Stripe: {
|
|
|
|
scope: "read_only",
|
|
|
|
endpoint: "https://connect.stripe.com/oauth/authorize",
|
|
|
|
},
|
|
|
|
TikTok: {
|
|
|
|
scope: "user.info.basic",
|
|
|
|
endpoint: "https://www.tiktok.com/auth/authorize/",
|
|
|
|
},
|
|
|
|
Tumblr: {
|
|
|
|
scope: "email",
|
|
|
|
endpoint: "https://www.tumblr.com/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Twitch: {
|
|
|
|
scope: "user_read",
|
|
|
|
endpoint: "https://id.twitch.tv/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Twitter: {
|
|
|
|
scope: "users.read",
|
|
|
|
endpoint: "https://twitter.com/i/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Typetalk: {
|
|
|
|
scope: "my",
|
|
|
|
endpoint: "https://typetalk.com/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Uber: {
|
|
|
|
scope: "profile",
|
|
|
|
endpoint: "https://login.uber.com/oauth/v2/authorize",
|
|
|
|
},
|
|
|
|
VK: {
|
|
|
|
scope: "email",
|
|
|
|
endpoint: "https://oauth.vk.com/authorize",
|
|
|
|
},
|
|
|
|
Wepay: {
|
|
|
|
scope: "manage_accounts%20view_user",
|
|
|
|
endpoint: "https://www.wepay.com/v2/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Xero: {
|
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "https://login.xero.com/identity/connect/authorize",
|
|
|
|
},
|
|
|
|
Yahoo: {
|
|
|
|
scope: "openid%20profile%20email",
|
|
|
|
endpoint: "https://api.login.yahoo.com/oauth2/request_auth",
|
|
|
|
},
|
|
|
|
Yammer: {
|
|
|
|
scope: "user",
|
|
|
|
endpoint: "https://www.yammer.com/oauth2/authorize",
|
|
|
|
},
|
|
|
|
Yandex: {
|
|
|
|
scope: "login:email",
|
|
|
|
endpoint: "https://oauth.yandex.com/authorize",
|
|
|
|
},
|
|
|
|
Zoom: {
|
|
|
|
scope: "user:read",
|
|
|
|
endpoint: "https://zoom.us/oauth/authorize",
|
|
|
|
},
|
2023-07-20 17:51:36 +08:00
|
|
|
MetaMask: {
|
|
|
|
scope: "",
|
|
|
|
endpoint: "",
|
|
|
|
},
|
2023-08-13 23:58:57 +08:00
|
|
|
Web3Onboard: {
|
|
|
|
scope: "",
|
|
|
|
endpoint: "",
|
|
|
|
},
|
2021-10-10 00:04:25 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
export function getProviderUrl(provider) {
|
|
|
|
if (provider.category === "OAuth") {
|
|
|
|
const endpoint = authInfo[provider.type].endpoint;
|
|
|
|
const urlObj = new URL(endpoint);
|
2021-10-09 22:33:39 +08:00
|
|
|
|
2021-10-10 00:04:25 +08:00
|
|
|
let host = urlObj.host;
|
|
|
|
let tokens = host.split(".");
|
|
|
|
if (tokens.length > 2) {
|
|
|
|
tokens = tokens.slice(1);
|
|
|
|
}
|
|
|
|
host = tokens.join(".");
|
2021-10-09 22:33:39 +08:00
|
|
|
|
2021-10-10 00:04:25 +08:00
|
|
|
return `${urlObj.protocol}//${host}`;
|
|
|
|
} else {
|
2022-08-17 22:02:45 +08:00
|
|
|
const info = Setting.OtherProviderInfo[provider.category][provider.type];
|
|
|
|
// avoid crash when provider is not found
|
|
|
|
if (info) {
|
|
|
|
return info.url;
|
|
|
|
}
|
|
|
|
return "";
|
2021-10-10 00:04:25 +08:00
|
|
|
}
|
2021-10-09 22:33:39 +08:00
|
|
|
}
|
|
|
|
|
2021-11-28 18:46:20 +08:00
|
|
|
export function getProviderLogoWidget(provider) {
|
|
|
|
if (provider === undefined) {
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
|
|
|
|
const url = getProviderUrl(provider);
|
|
|
|
if (url !== "") {
|
|
|
|
return (
|
|
|
|
<Tooltip title={provider.type}>
|
|
|
|
<a target="_blank" rel="noreferrer" href={getProviderUrl(provider)}>
|
2022-04-21 21:52:34 +08:00
|
|
|
<img width={36} height={36} src={Setting.getProviderLogoURL(provider)} alt={provider.displayName} />
|
2021-11-28 18:46:20 +08:00
|
|
|
</a>
|
|
|
|
</Tooltip>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2021-11-28 18:46:20 +08:00
|
|
|
} else {
|
|
|
|
return (
|
|
|
|
<Tooltip title={provider.type}>
|
2022-04-21 21:52:34 +08:00
|
|
|
<img width={36} height={36} src={Setting.getProviderLogoURL(provider)} alt={provider.displayName} />
|
2021-11-28 18:46:20 +08:00
|
|
|
</Tooltip>
|
2022-07-10 15:45:55 +08:00
|
|
|
);
|
2021-11-28 18:46:20 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-14 21:21:42 +08:00
|
|
|
export function getAuthUrl(application, provider, method) {
|
2021-04-19 01:14:41 +08:00
|
|
|
if (application === null || provider === null) {
|
|
|
|
return "";
|
|
|
|
}
|
|
|
|
|
2022-01-28 23:57:54 +08:00
|
|
|
let endpoint = authInfo[provider.type].endpoint;
|
2023-09-18 15:42:00 +08:00
|
|
|
let redirectUri = `${window.location.origin}/callback`;
|
2021-10-09 22:15:43 +08:00
|
|
|
const scope = authInfo[provider.type].scope;
|
2022-09-09 11:43:54 +08:00
|
|
|
|
2023-11-19 07:30:29 +08:00
|
|
|
const isShortState = (provider.type === "WeChat" && navigator.userAgent.includes("MicroMessenger")) || (provider.type === "Twitter");
|
2022-09-09 11:43:54 +08:00
|
|
|
const state = Util.getStateFromQueryParams(application.name, provider.name, method, isShortState);
|
2023-02-04 12:20:18 +08:00
|
|
|
const codeChallenge = "P3S-a7dr8bgM4bF6vOyiKkKETDl16rcAzao9F8UIL1Y"; // SHA256(Base64-URL-encode("casdoor-verifier"))
|
2021-10-09 22:15:43 +08:00
|
|
|
|
2023-03-23 22:37:53 +08:00
|
|
|
if (provider.type === "AzureAD") {
|
|
|
|
if (provider.domain !== "") {
|
|
|
|
endpoint = endpoint.replace("common", provider.domain);
|
|
|
|
}
|
2023-09-18 15:42:00 +08:00
|
|
|
} else if (provider.type === "Apple") {
|
|
|
|
redirectUri = `${window.location.origin}/api/callback`;
|
2023-03-23 22:37:53 +08:00
|
|
|
}
|
|
|
|
|
2023-03-09 21:11:16 +08:00
|
|
|
if (provider.type === "Google" || provider.type === "GitHub" || provider.type === "QQ" || provider.type === "Facebook"
|
2023-02-04 12:20:18 +08:00
|
|
|
|| provider.type === "Weibo" || provider.type === "Gitee" || provider.type === "LinkedIn" || provider.type === "GitLab" || provider.type === "AzureAD"
|
|
|
|
|| provider.type === "Slack" || provider.type === "Line" || provider.type === "Amazon" || provider.type === "Auth0" || provider.type === "BattleNet"
|
|
|
|
|| provider.type === "Bitbucket" || provider.type === "Box" || provider.type === "CloudFoundry" || provider.type === "Dailymotion"
|
|
|
|
|| provider.type === "DigitalOcean" || provider.type === "Discord" || provider.type === "Dropbox" || provider.type === "EveOnline" || provider.type === "Gitea"
|
|
|
|
|| provider.type === "Heroku" || provider.type === "InfluxCloud" || provider.type === "Instagram" || provider.type === "Intercom" || provider.type === "Kakao"
|
|
|
|
|| provider.type === "MailRu" || provider.type === "Meetup" || provider.type === "MicrosoftOnline" || provider.type === "Naver" || provider.type === "Nextcloud"
|
|
|
|
|| provider.type === "OneDrive" || provider.type === "Oura" || provider.type === "Patreon" || provider.type === "PayPal" || provider.type === "SalesForce"
|
|
|
|
|| provider.type === "SoundCloud" || provider.type === "Spotify" || provider.type === "Strava" || provider.type === "Stripe" || provider.type === "Tumblr"
|
|
|
|
|| provider.type === "Twitch" || provider.type === "Typetalk" || provider.type === "Uber" || provider.type === "VK" || provider.type === "Wepay"
|
|
|
|
|| provider.type === "Xero" || provider.type === "Yahoo" || provider.type === "Yammer" || provider.type === "Yandex" || provider.type === "Zoom") {
|
2021-10-09 22:15:43 +08:00
|
|
|
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}`;
|
2023-03-09 21:11:16 +08:00
|
|
|
} else if (provider.type === "DingTalk") {
|
|
|
|
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&prompt=consent&state=${state}`;
|
2021-03-28 20:20:40 +08:00
|
|
|
} else if (provider.type === "WeChat") {
|
2021-12-20 23:36:28 +08:00
|
|
|
if (navigator.userAgent.includes("MicroMessenger")) {
|
2021-12-20 23:46:38 +08:00
|
|
|
return `${authInfo[provider.type].mpEndpoint}?appid=${provider.clientId2}&redirect_uri=${redirectUri}&state=${state}&scope=${authInfo[provider.type].mpScope}&response_type=code#wechat_redirect`;
|
2021-12-20 20:21:12 +08:00
|
|
|
} else {
|
2021-12-20 23:36:28 +08:00
|
|
|
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&response_type=code&state=${state}#wechat_redirect`;
|
2021-12-20 20:21:12 +08:00
|
|
|
}
|
2021-08-14 16:00:38 +08:00
|
|
|
} else if (provider.type === "WeCom") {
|
2022-01-28 23:57:54 +08:00
|
|
|
if (provider.subType === "Internal") {
|
|
|
|
if (provider.method === "Silent") {
|
|
|
|
endpoint = authInfo[provider.type].silentEndpoint;
|
|
|
|
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&scope=${scope}&response_type=code#wechat_redirect`;
|
|
|
|
} else if (provider.method === "Normal") {
|
|
|
|
endpoint = authInfo[provider.type].internalEndpoint;
|
|
|
|
return `${endpoint}?appid=${provider.clientId}&agentid=${provider.appId}&redirect_uri=${redirectUri}&state=${state}&usertype=member`;
|
|
|
|
} else {
|
|
|
|
return `https://error:not-supported-provider-method:${provider.method}`;
|
|
|
|
}
|
|
|
|
} else if (provider.subType === "Third-party") {
|
|
|
|
if (provider.method === "Silent") {
|
|
|
|
endpoint = authInfo[provider.type].silentEndpoint;
|
|
|
|
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&scope=${scope}&response_type=code#wechat_redirect`;
|
|
|
|
} else if (provider.method === "Normal") {
|
|
|
|
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&usertype=member`;
|
|
|
|
} else {
|
|
|
|
return `https://error:not-supported-provider-method:${provider.method}`;
|
|
|
|
}
|
2021-08-23 22:25:55 +08:00
|
|
|
} else {
|
2022-01-28 23:57:54 +08:00
|
|
|
return `https://error:not-supported-provider-sub-type:${provider.subType}`;
|
2021-08-23 22:25:55 +08:00
|
|
|
}
|
2021-08-14 16:00:38 +08:00
|
|
|
} else if (provider.type === "Lark") {
|
2021-10-09 22:15:43 +08:00
|
|
|
return `${endpoint}?app_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}`;
|
2023-07-30 17:31:36 +08:00
|
|
|
} else if (provider.type === "ADFS") {
|
2022-02-20 15:01:48 +08:00
|
|
|
return `${provider.domain}/adfs/oauth2/authorize?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&nonce=casdoor&scope=openid`;
|
2022-01-22 19:36:44 +08:00
|
|
|
} else if (provider.type === "Baidu") {
|
|
|
|
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}&display=popup`;
|
2022-04-02 22:37:13 +08:00
|
|
|
} else if (provider.type === "Alipay") {
|
|
|
|
return `${endpoint}?app_id=${provider.clientId}&scope=auth_user&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}&display=popup`;
|
2022-03-18 18:28:46 +08:00
|
|
|
} else if (provider.type === "Casdoor") {
|
|
|
|
return `${provider.domain}/login/oauth/authorize?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
|
2022-07-10 15:45:55 +08:00
|
|
|
} else if (provider.type === "Infoflow") {
|
|
|
|
return `${endpoint}?appid=${provider.clientId}&redirect_uri=${redirectUri}?state=${state}`;
|
2021-12-10 00:55:27 +08:00
|
|
|
} else if (provider.type === "Apple") {
|
2023-09-18 15:42:00 +08:00
|
|
|
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code%20id_token&scope=${scope}&response_mode=form_post`;
|
2022-02-16 19:57:46 +08:00
|
|
|
} else if (provider.type === "Steam") {
|
|
|
|
return `${endpoint}?openid.claimed_id=http://specs.openid.net/auth/2.0/identifier_select&openid.identity=http://specs.openid.net/auth/2.0/identifier_select&openid.mode=checkid_setup&openid.ns=http://specs.openid.net/auth/2.0&openid.realm=${window.location.origin}&openid.return_to=${redirectUri}?state=${state}`;
|
2022-05-01 18:31:42 +08:00
|
|
|
} else if (provider.type === "Okta") {
|
|
|
|
return `${provider.domain}/v1/authorize?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
|
2023-02-04 12:20:18 +08:00
|
|
|
} else if (provider.type === "Douyin" || provider.type === "TikTok") {
|
2022-05-15 20:59:21 +08:00
|
|
|
return `${endpoint}?client_key=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}`;
|
2022-04-16 17:17:45 +08:00
|
|
|
} else if (provider.type === "Custom") {
|
2023-07-05 20:35:02 +08:00
|
|
|
return `${provider.customAuthUrl}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${provider.scopes}&response_type=code&state=${state}`;
|
2022-05-12 10:07:52 +08:00
|
|
|
} else if (provider.type === "Bilibili") {
|
2022-07-10 15:45:55 +08:00
|
|
|
return `${endpoint}#/?client_id=${provider.clientId}&return_url=${redirectUri}&state=${state}&response_type=code`;
|
2023-02-04 12:20:18 +08:00
|
|
|
} else if (provider.type === "Deezer") {
|
|
|
|
return `${endpoint}?app_id=${provider.clientId}&redirect_uri=${redirectUri}&perms=${scope}`;
|
|
|
|
} else if (provider.type === "Lastfm") {
|
|
|
|
return `${endpoint}?api_key=${provider.clientId}&cb=${redirectUri}`;
|
|
|
|
} else if (provider.type === "Shopify") {
|
|
|
|
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&scope=${scope}&state=${state}&grant_options[]=per-user`;
|
|
|
|
} else if (provider.type === "Twitter" || provider.type === "Fitbit") {
|
|
|
|
return `${endpoint}?client_id=${provider.clientId}&redirect_uri=${redirectUri}&state=${state}&response_type=code&scope=${scope}&code_challenge=${codeChallenge}&code_challenge_method=S256`;
|
2023-07-20 17:51:36 +08:00
|
|
|
} else if (provider.type === "MetaMask") {
|
|
|
|
return `${redirectUri}?state=${state}`;
|
2023-08-13 23:58:57 +08:00
|
|
|
} else if (provider.type === "Web3Onboard") {
|
|
|
|
return `${redirectUri}?state=${state}`;
|
2022-05-12 10:07:52 +08:00
|
|
|
}
|
2021-02-14 16:59:08 +08:00
|
|
|
}
|