Skip to content

Commit

Permalink
Merge
Browse files Browse the repository at this point in the history
  • Loading branch information
yelexin committed Mar 23, 2020
2 parents 40d6dd1 + e49bc77 commit bf6b93a
Show file tree
Hide file tree
Showing 12 changed files with 302 additions and 198 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
},
"dependencies": {
"@authing/sso": "^1.3.0",
"authing-js-sdk": "3.5.0",
"authing-js-sdk": "^3.16.5",
"axios": "^0.18.0",
"otplib": "^11.0.1",
"qrcode": "^1.4.1",
Expand Down
196 changes: 103 additions & 93 deletions public/index.html
Original file line number Diff line number Diff line change
@@ -1,98 +1,108 @@
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="https://fe-static.authing.cn/dist/favicon.png" />
<title>Authing SSO</title>
</head>

<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width,initial-scale=1.0" />
<link rel="icon" href="https://fe-static.authing.cn/dist/favicon.png" />
<title>Authing SSO</title>
</head>

<body>
<noscript>
<strong>We're sorry but sso doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong>
</noscript>
<div id="app"></div>
</body>
<script>
/* 测试 LoginForm */
// let clientId = '5cbd6716aaaa70cb9a58d86f'
// const guard = new AuthingGuard(clientId, undefined, {
// hideClose: true,
// isSSO: false,
// qrcodeScanning: {
// redirect: false,
// },
// logo: "https://usercontents.authing.cn/client/[email protected]",
// title: "Authing",
// host: {
// user: 'http://localhost:5555/graphql',
// oauth: 'http://localhost:5556/graphql',
// // user: 'https://users.authing.cn/graphql',
// // oauth: 'https://oauth.authing.cn/graphql'
// }
// });
// guard.on('authenticated', data => {
// console.log(data)
// })
// guard.on('register', data => {
// console.log(data)
// })
/* 测试 SSO */
String.prototype.endsWith = function (suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
const getQueryString = function (name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
} else {
return null;
}
};
let hostName = location.hostname;
let EndpointSwitch = {
"littleimp.cn": [
"https://core.littleimp.cn/graphql",
"https://core.littleimp.cn/graphql"
],
localhost: ["http://localhost:5510", "http://localhost:5510"]
};
function getEndpoint(hostName) {
for (index in EndpointSwitch) {
window.isDev = true;
if (hostName.endsWith(index)) {
return EndpointSwitch[index];
<body>
<noscript>
<strong
>We're sorry but sso doesn't work properly without JavaScript enabled.
Please enable it to continue.</strong
>
</noscript>
<div id="app"></div>
</body>
<script>
window.onload = function resize() {
// 防止移动端登录按钮被遮挡
document.getElementsByClassName(
"authing-login-form-wrapper"
)[0].style.height = window.innerHeight + "px";
};
/* 测试 LoginForm */
// let clientId = '5cbd6716aaaa70cb9a58d86f'
// const guard = new AuthingGuard(clientId, undefined, {
// hideClose: true,
// isSSO: false,
// qrcodeScanning: {
// redirect: false,
// },
// logo: "https://usercontents.authing.cn/client/[email protected]",
// title: "Authing",
// host: {
// user: 'http://localhost:5555/graphql',
// oauth: 'http://localhost:5556/graphql',
// // user: 'https://users.authing.cn/graphql',
// // oauth: 'https://oauth.authing.cn/graphql'
// }
// });
// guard.on('authenticated', data => {
// console.log(data)
// })
// guard.on('register', data => {
// console.log(data)
// })
/* 测试 SSO */
String.prototype.endsWith = function(suffix) {
return this.indexOf(suffix, this.length - suffix.length) !== -1;
};
const getQueryString = function(name) {
var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
var r = window.location.search.substr(1).match(reg);
if (r != null) {
return unescape(r[2]);
} else {
return null;
}
};
let hostName = location.hostname;
let EndpointSwitch = {
"littleimp.cn": [
"https://core.littleimp.cn/graphql",
"https://core.littleimp.cn/graphql"
],
"celebes.live": [
"https://core.celebes.live/graphql",
"https://core.celebes.live/graphql"
],
localhost: ["http://localhost:5510", "http://localhost:5510"]
};
function getEndpoint(hostName) {
for (index in EndpointSwitch) {
window.isDev = true;
if (hostName.endsWith(index)) {
return EndpointSwitch[index];
}
}
window.isDev = false;
return [
"https://users.authing.cn/graphql",
"https://oauth.authing.cn/graphql"
];
}
window.isDev = false;
return [
"https://users.authing.cn/graphql",
"https://oauth.authing.cn/graphql"
];
};
// let [userGqlEndPoint, oauthGqlEndPoint] = getEndpoint(hostName);
let userGqlEndPoint = getEndpoint(hostName)[0]
let oauthGqlEndPoint = getEndpoint(hostName)[1]
let appId = getQueryString("app_id") || getQueryString("client_id");
const guard = new Guard(undefined, {
appId: appId,
hideClose: true,
isSSO: true,
SSOHost: location.origin, // 开发模式下,会代理转发到 localhost:5556/authorize
// SSOHost: 'https://sso.authing.cn',
qrcodeScanning: {
redirect: false
},
host: {
user: userGqlEndPoint,
oauth: oauthGqlEndPoint
},
passwordEncPublicKey: undefined
});
</script>

</html>
// let [userGqlEndPoint, oauthGqlEndPoint] = getEndpoint(hostName);
let userGqlEndPoint = getEndpoint(hostName)[0];
let oauthGqlEndPoint = getEndpoint(hostName)[1];
let appId = getQueryString("app_id") || getQueryString("client_id");
const guard = new Guard(undefined, {
appId: appId,
hideClose: true,
isSSO: true,
SSOHost: location.origin, // 开发模式下,会代理转发到 localhost:5556/authorize
// SSOHost: 'https://sso.authing.cn',
qrcodeScanning: {
redirect: false
},
host: {
user: userGqlEndPoint,
oauth: oauthGqlEndPoint
},
passwordEncPublicKey: undefined
});
</script>
</html>
Loading

0 comments on commit bf6b93a

Please sign in to comment.