-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added User table and middleware around user creation.
1. Added user table. 2. Added Middleware around upserting/rejecting users. 3. Created script to bulk migrate all questionnaires. 4. Added migration script to update questionnaires with users. 5. Added proxy to the f/e app.
- Loading branch information
SamGodwin2
committed
Jun 11, 2019
1 parent
ca7eae1
commit 9a87d90
Showing
151 changed files
with
2,007 additions
and
1,369 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
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 @@ | ||
module.exports.AUTHOR_TEAM_NAME = "Author Team"; |
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
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
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,61 @@ | ||
keys: | ||
publisher: | ||
value: | | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEpAIBAAKCAQEApEJbinF5XUgXS9MTqwYyDClmEYHQRW4T20ofE+9568GVAGwy | ||
n80T0F8sLM3bW9GNj3xxnd/4NKG/E8kD3pXNq2IdBoCpr6OOJgs/JY+5aztOIQpl | ||
cxzy0jH6BPAVBkmNwmx1ebsDRdZMjQwvOAFTce/8vhH+xRFFChX5cE3n3MZg+5Fy | ||
DlXePbXNWwHEY0CWLD317FNKJt1IS5JanjY0jHKX3/+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Fni3CdxzrQKBgQCCRZJfT7d34ICFTGs98o41h29gZ6Hd+Ops6Jn+ | ||
F1shQPVSp75hciShrfNRkLuLbgoqRo/HSmbVCKO1SzIBoY4EQ0pthPq/M5+x+SQ4 | ||
dieMppVrISl9/s0FOXtvGj8N5dHcNjATG7jsUoCcrGiDz/aWytopignNjMqSSfuL | ||
6ZN0MQKBgQCfJfk/SOl+niT7gdyN+Fc+TNwBoTIsrIm6VOOkDSCxKR5qY0cIAE1j | ||
yZW1CKeZg5kcYP66JmGAFZq87ouHygCXFkZkcaboYjV6URL+4vRRiQYt4TUQGiJm | ||
LKpPms/WjRAUCxnsslcURTcTYehZAeOAic9ITWv1ppr6AN3AL71qdQ== | ||
-----END RSA PRIVATE KEY----- | ||
use: signing | ||
notPublisher: | ||
value: | | ||
-----BEGIN RSA PRIVATE KEY----- | ||
MIIEpAIBAAKCAQEAvRLvLCpQzpZXqEeZMcFqzlumtDoC5D6jAbBflHBKCpl9uIeG | ||
0UwAyherdvv2782LvI4VYELgQ7+4QUIFBONBkt08Cosx1Fg3I426AbwvnXZeaNq2 | ||
mrV1J7111pURZ77oAIWTX5rwn0AUHLXK0KFy2PkdishJ8LPEi9ow/8NOmmjXrdvx | ||
RUVTrddqqqxEJEoyG2dG9SFMYamx6f6sAI35Aocxr6X8jqeKqg85IOx/B/1RMxM8 | ||
9SvDyAP6gdSF4aL8nU4uOTX7gHlIjpHWE2C24DtOSJ0pywUOi3iMHwSqL/hBGSP2 | ||
fCRJWo1+Zk0OA/R9bI3InKXtqt3TpO/Zu1qtQQIDAQABAoIBAQCfIuibS6JnvrJY | ||
uKp/7kNvHETbPFhiszWPnltUHI61DSt7vNYEIuwnLHTs2HWmsGIEebIUKzWG0D7M | ||
7jw7OOtgKUT3uuBd0UHXctozy6hn59Def/dhj4jjwdsEmMLlhxDOH59CwK3124ES | ||
CRCDON/pLwNmY92X8jZjX2oOWtw1qMVjdy7qwbOty/QByEKQMg2HOtD8GCnlM7U+ | ||
YmHQF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| ||
-----END RSA PRIVATE KEY----- | ||
use: signing |
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
This file was deleted.
Oops, something went wrong.
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,61 @@ | ||
const verifyServiceRequest = require("./verifyServiceRequest"); | ||
const { isNil, isEmpty } = require("lodash/fp"); | ||
const jwt = require("jsonwebtoken"); | ||
const { getUserByExternalId } = require("../../utils/datastore"); | ||
|
||
module.exports = logger => async (req, res, next) => { | ||
const authHeader = req.header(process.env.AUTH_HEADER_KEY || "authorization"); | ||
if (isNil(authHeader)) { | ||
logger.error("Request must contain a valid authorization header."); | ||
res.send(401); | ||
return; | ||
} | ||
|
||
const accessToken = authHeader.replace("Bearer ", "").replace(/=/g, ""); | ||
if (isEmpty(accessToken)) { | ||
logger.error("Request must contain a valid access token."); | ||
res.send(401); | ||
return; | ||
} | ||
|
||
const jwtToken = jwt.decode(accessToken); | ||
if (isNil(jwtToken)) { | ||
logger.error("Could not decode JWT token."); | ||
res.send(401); | ||
return; | ||
} | ||
|
||
if (jwtToken.serviceName) { | ||
await verifyServiceRequest(accessToken, jwtToken.serviceName); | ||
req.user = { | ||
id: jwtToken.serviceName, | ||
name: jwtToken.serviceName, | ||
isVerified: true, | ||
}; | ||
next(); | ||
return; | ||
} | ||
|
||
let user = await getUserByExternalId(jwtToken.sub); | ||
if (!user) { | ||
req.user = { | ||
name: jwtToken.name, | ||
externalId: jwtToken.sub, | ||
email: jwtToken.email, | ||
isVerified: false, | ||
}; | ||
next(); | ||
return; | ||
} | ||
|
||
req.user = { | ||
id: user.id, | ||
name: jwtToken.name, | ||
externalId: jwtToken.sub, | ||
email: jwtToken.email, | ||
isVerified: true, | ||
}; | ||
|
||
next(); | ||
return; | ||
}; |
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
8 changes: 8 additions & 0 deletions
8
eq-author-api/middleware/identification/rejectUnidentifiedUsers.js
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,8 @@ | ||
module.exports = async (req, res, next) => { | ||
if (!req.user.isVerified) { | ||
res.status(401).send("User does not exist"); | ||
return; | ||
} | ||
|
||
next(); | ||
}; |
Oops, something went wrong.