This commit is contained in:
aozhiwei 2024-06-29 10:47:33 +08:00
parent fc6130fdb2
commit 5f052f7efa
3 changed files with 0 additions and 1296 deletions

View File

@ -1,32 +0,0 @@
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');
});

File diff suppressed because it is too large Load Diff

View File

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