This commit is contained in:
aozhiwei 2024-05-29 11:57:43 +08:00
parent 655325d631
commit d6f330ae79
3 changed files with 1296 additions and 0 deletions

32
server/web3test/app.js Normal file
View File

@ -0,0 +1,32 @@
const express = require('express');
const { auth, requiresAuth } = require('express-openid-connect');
const app = express();
const config = {
authRequired: false,
auth0Logout: true,
baseURL: 'http://localhost:3000',
clientID: '{yourClientId}',
issuerBaseURL: 'https://{yourDomain}',
secret: 'LONG_RANDOM_STRING'
};
// The `auth` router attaches /login, /logout
// and /callback routes to the baseURL
app.use(auth(config));
// req.oidc.isAuthenticated is provided from the auth router
app.get('/', (req, res) => {
res.send(
req.oidc.isAuthenticated() ? 'Logged in' : 'Logged out'
);
});
// The /profile route will show the user profile as JSON
app.get('/profile', requiresAuth(), (req, res) => {
res.send(JSON.stringify(req.oidc.user, null, 2));
});
app.listen(3000, function() {
console.log('Listening on http://localhost:3000');
});

1258
server/web3test/package-lock.json generated Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,6 @@
{
"dependencies": {
"express": "^4.19.2",
"express-openid-connect": "^2.17.1"
}
}