Skip to content

Commit

Permalink
added inital code with auth0 implemented
Browse files Browse the repository at this point in the history
  • Loading branch information
Rish7223 committed May 19, 2021
0 parents commit 79c3602
Show file tree
Hide file tree
Showing 5 changed files with 894 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
/node_modules
.env
3 changes: 3 additions & 0 deletions .prettierrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"singleQuote": true
}
30 changes: 30 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
const express = require('express');
const { auth, requiresAuth } = require('express-openid-connect');
require('dotenv').config();
const app = express();

app.use(
auth({
authRequired: false,
auth0Logout: true,
baseURL: process.env.BASE_URL,
clientID: process.env.CLIENT_ID,
issuerBaseURL: process.env.ISSUER_BASE_URL,
secret: process.env.SECRET,
})
);

app.get('/', (req, res) => {
res.send(req.oidc.isAuthenticated() ? 'Logged in' : 'Logged out');
});

app.get('/profile', requiresAuth(), (req, res) => {
const data = req.oidc.user;
console.log(data);
res.send(JSON.stringify(data));
});

const PORT = process.env.PORT || 4000;
app.listen(PORT, () => {
console.log('server is listing on port 400');
});
Loading

0 comments on commit 79c3602

Please sign in to comment.