1
This commit is contained in:
parent
655325d631
commit
d6f330ae79
32
server/web3test/app.js
Normal file
32
server/web3test/app.js
Normal 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
1258
server/web3test/package-lock.json
generated
Normal file
File diff suppressed because it is too large
Load Diff
6
server/web3test/package.json
Normal file
6
server/web3test/package.json
Normal file
@ -0,0 +1,6 @@
|
||||
{
|
||||
"dependencies": {
|
||||
"express": "^4.19.2",
|
||||
"express-openid-connect": "^2.17.1"
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user