chore: add oidc page test server

perf/livekit-chat-count
moonrailgun 2 years ago
parent 23b1a851a9
commit 2dfe88b5dd

@ -2248,6 +2248,22 @@ importers:
specifier: ^4.17.2
version: 4.18.2
devDependencies:
'@types/express':
specifier: ^4.17.15
version: 4.17.15
ts-node:
specifier: 10.9.1
version: 10.9.1(@types/node@18.11.9)(typescript@4.9.4)
server/test/demo/openapi-oidc-page:
dependencies:
express:
specifier: ^4.17.2
version: 4.18.2
devDependencies:
'@types/express':
specifier: ^4.17.15
version: 4.17.17
ts-node:
specifier: 10.9.1
version: 10.9.1(@types/node@18.11.9)(typescript@4.9.4)

@ -80,7 +80,7 @@ app.get('/cb', async (req, res, next) => {
app.listen(port, () => {
console.log(
`请确保第三方登录功能已启动并且回调已经被注册在OIDC服务端的白名单中: ${clientUrl}/cb`
`Please ensure that the third-party login function is enabled and the callback has been registered in the whitelist of the OIDC server: ${clientUrl}/cb`
);
console.log(`测试服务地址: http://127.0.0.1:${port}`);
console.log(`Test Server Address: http://127.0.0.1:${port}`);
});

@ -15,6 +15,7 @@
"express": "^4.17.2"
},
"devDependencies": {
"@types/express": "^4.17.15",
"ts-node": "10.9.1"
}
}

@ -0,0 +1,67 @@
import express from 'express';
import path from 'path';
import ejs from 'ejs';
const app = express();
const port = process.env.PORT || 8080;
const publicDir = path.resolve(__dirname, '../../../public');
const viewRootDir = path.resolve(
__dirname,
'../../../services/openapi/oidc/views'
);
app.use(express.static(publicDir));
app.get('/', (req, res) => {
res.send(
`<ul>${['/login', '/authorize', '/error']
.map((p) => `<li><a href=${p}>${p}</a></li>`)
.join('\n')}</ul>`
);
});
app.get('/login', async (req, res) => {
const data = {
uid: 'fooooooooo',
};
const html = await ejs.renderFile(
path.resolve(viewRootDir, './login.ejs'),
data
);
res.send(html);
});
app.get('/error', async (req, res) => {
const data = {
text: 'fooooooooo',
};
const html = await ejs.renderFile(
path.resolve(viewRootDir, './error.ejs'),
data
);
res.send(html);
});
app.get('/authorize', async (req, res) => {
const data = {
logoUri: 'loginUrl',
clientName: 'Test',
uid: 'foooo',
details: {},
params: {},
session: '',
};
const html = await ejs.renderFile(
path.resolve(viewRootDir, './authorize.ejs'),
data
);
res.send(html);
});
app.listen(port, () => {
console.log(`Server: http://127.0.0.1:${port}`);
});

@ -0,0 +1,20 @@
{
"name": "openapi-oidc-page",
"version": "1.0.0",
"description": "",
"private": true,
"main": "index.js",
"scripts": {
"start": "ts-node ./index.ts",
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"express": "^4.17.2"
},
"devDependencies": {
"@types/express": "^4.17.15",
"ts-node": "10.9.1"
}
}
Loading…
Cancel
Save