-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
# Conflicts: # src/config/configuration.js # src/resources/collections/collections.model.js # src/resources/collections/collections.route.js # src/resources/course/course.model.js # src/resources/datarequest/datarequest.controller.js # src/resources/dataset/dataset.route.js # src/resources/dataset/dataset.service.js # src/resources/relatedobjects/relatedobjects.route.js # src/resources/stats/stats.router.js # src/resources/tool/data.model.js # src/resources/utilities/emailGenerator.util.js
- Loading branch information
Showing
111 changed files
with
14,825 additions
and
10,103 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,11 @@ | ||
{ | ||
"arrowParens": "avoid", | ||
"bracketSpacing": true, | ||
"trailingComma": "es5", | ||
"useTabs": true, | ||
"semi": true, | ||
"singleQuote": true, | ||
"jsxSingleQuote": true, | ||
"jsxBracketSameLine": true, | ||
"printWidth": 140 | ||
} |
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,19 @@ | ||
steps: | ||
- name: 'gcr.io/cloud-builders/docker' | ||
entrypoint: 'bash' | ||
args: ['-c', 'docker pull gcr.io/$PROJECT_ID/${_APP_NAME}:${_ENVIRONMENT} || exit 0'] | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: [ | ||
'build', | ||
'-t', 'gcr.io/$PROJECT_ID/${_APP_NAME}:${_ENVIRONMENT}', | ||
'--cache-from', 'gcr.io/$PROJECT_ID/${_APP_NAME}:${_ENVIRONMENT}', | ||
'.' | ||
] | ||
- name: 'gcr.io/cloud-builders/docker' | ||
args: ['push', 'gcr.io/$PROJECT_ID/${_APP_NAME}:${_ENVIRONMENT}'] | ||
- name: 'gcr.io/cloud-builders/gcloud' | ||
args: ['run', 'deploy', '${_ENVIRONMENT}-api', '--image', 'gcr.io/$PROJECT_ID/${_APP_NAME}:${_ENVIRONMENT}', '--platform', 'managed', '--region', '${_REGION}', '--allow-unauthenticated'] | ||
images: | ||
- gcr.io/$PROJECT_ID/${_APP_NAME}:${_ENVIRONMENT} | ||
options: | ||
machineType: 'E2_HIGHCPU_8' |
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 |
---|---|---|
@@ -1,67 +1,68 @@ | ||
import { getUserByUserId } from '../resources/user/user.repository'; | ||
import { to } from 'await-to-js' | ||
import { to } from 'await-to-js'; | ||
|
||
const store = new Map(); | ||
const logins = new Map(); | ||
const { nanoid } = require('nanoid'); | ||
|
||
|
||
class Account { | ||
constructor(id, profile) { | ||
this.accountId = id || nanoid(); | ||
this.profile = profile; | ||
store.set(this.accountId, this); | ||
} | ||
constructor(id, profile) { | ||
this.accountId = id || nanoid(); | ||
this.profile = profile; | ||
store.set(this.accountId, this); | ||
} | ||
|
||
/** | ||
* @param use - can either be "id_token" or "userinfo", depending on | ||
* where the specific claims are intended to be put in. | ||
* @param scope - the intended scope, while oidc-provider will mask | ||
* claims depending on the scope automatically you might want to skip | ||
* loading some claims from external resources etc. based on this detail | ||
* or not return them in id tokens but only userinfo and so on. | ||
*/ | ||
async claims(use, scope) { // eslint-disable-line no-unused-vars | ||
if (this.profile) { | ||
return { | ||
sub: this.accountId, // it is essential to always return a sub claim | ||
email: this.profile.email, | ||
firstname: this.profile.firstname, | ||
lastname: this.profile.lastname | ||
}; | ||
} | ||
/** | ||
* @param use - can either be "id_token" or "userinfo", depending on | ||
* where the specific claims are intended to be put in. | ||
* @param scope - the intended scope, while oidc-provider will mask | ||
* claims depending on the scope automatically you might want to skip | ||
* loading some claims from external resources etc. based on this detail | ||
* or not return them in id tokens but only userinfo and so on. | ||
*/ | ||
async claims(use, scope) { | ||
// eslint-disable-line no-unused-vars | ||
if (this.profile) { | ||
return { | ||
sub: this.accountId, // it is essential to always return a sub claim | ||
email: this.profile.email, | ||
firstname: this.profile.firstname, | ||
lastname: this.profile.lastname, | ||
}; | ||
} | ||
|
||
return { | ||
sub: this.accountId, // it is essential to always return a sub claim | ||
}; | ||
} | ||
return { | ||
sub: this.accountId, // it is essential to always return a sub claim | ||
}; | ||
} | ||
|
||
static async findByFederated(provider, claims) { | ||
const id = `${provider}.${claims.sub}`; | ||
if (!logins.get(id)) { | ||
logins.set(id, new Account(id, claims)); | ||
} | ||
return logins.get(id); | ||
} | ||
static async findByFederated(provider, claims) { | ||
const id = `${provider}.${claims.sub}`; | ||
if (!logins.get(id)) { | ||
logins.set(id, new Account(id, claims)); | ||
} | ||
return logins.get(id); | ||
} | ||
|
||
static async findByLogin(login) { | ||
if (!logins.get(login)) { | ||
logins.set(login, new Account(login)); | ||
} | ||
static async findByLogin(login) { | ||
if (!logins.get(login)) { | ||
logins.set(login, new Account(login)); | ||
} | ||
|
||
return logins.get(login); | ||
} | ||
return logins.get(login); | ||
} | ||
|
||
static async findAccount(ctx, id, token) { // eslint-disable-line no-unused-vars | ||
// token is a reference to the token used for which a given account is being loaded, | ||
// it is undefined in scenarios where account claims are returned from authorization endpoint | ||
// ctx is the koa request context | ||
if (!store.get(id)) { | ||
let [err, user] = await to(getUserByUserId(parseInt(id))) | ||
new Account(id, user); // eslint-disable-line no-new | ||
} | ||
return store.get(id); | ||
} | ||
static async findAccount(ctx, id, token) { | ||
// eslint-disable-line no-unused-vars | ||
// token is a reference to the token used for which a given account is being loaded, | ||
// it is undefined in scenarios where account claims are returned from authorization endpoint | ||
// ctx is the koa request context | ||
if (!store.get(id)) { | ||
let [err, user] = await to(getUserByUserId(parseInt(id))); | ||
new Account(id, user); // eslint-disable-line no-new | ||
} | ||
return store.get(id); | ||
} | ||
} | ||
|
||
module.exports = Account; |
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
Oops, something went wrong.