the RE node api now uses OIDC

This commit is contained in:
Muhammad Azeez 2021-01-18 11:15:54 +03:00
parent 0f7550c362
commit 732f851302
4 changed files with 1499 additions and 1 deletions

View File

@ -2,11 +2,28 @@ const express = require('express')
const cors = require('cors')
const bodyParser = require('body-parser')
const db = require('./queries')
const jwt = require('express-jwt');
const jwksRsa = require('jwks-rsa');
const app = express()
app.use(cors())
const port = 8000
app.use(jwt({
// Dynamically provide a signing key based on the kid in the header and the signing keys provided by the JWKS endpoint.
secret: jwksRsa.expressJwtSecret({
cache: true,
rateLimit: true,
jwksRequestsPerMinute: 5,
jwksUri: `http://localhost:10000/.well-known/openid-configuration/jwks`
}),
// Validate the audience and the issuer.
audience: 'real-estate-api',
issuer: 'http://localhost:10000',
algorithms: [ 'RS256' ]
}));
app.use(bodyParser.json());
app.use(
bodyParser.urlencoded({

File diff suppressed because it is too large Load Diff

View File

@ -12,6 +12,8 @@
"dependencies": {
"cors": "^2.8.5",
"express": "^4.17.1",
"express-jwt": "^6.0.0",
"jwks-rsa": "^1.12.2",
"pg": "^8.5.1"
}
}

View File

@ -28,6 +28,7 @@ const VehiclesMain = () => {
async function getVehicles() {
console.log(user);
const vehicles = await apiService.getVehiclesFromApi(user.access_token);
console.log(vehicles);
setVehicleData(vehicles);
}