-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added inital code with auth0 implemented
- Loading branch information
0 parents
commit 79c3602
Showing
5 changed files
with
894 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
/node_modules | ||
.env |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
{ | ||
"singleQuote": true | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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'); | ||
}); |
Oops, something went wrong.