Skip to content

fully removed system user token usage #269

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Mar 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 0 additions & 2 deletions config/custom-environment-variables.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
"fileServiceEndpoint": "FILE_SERVICE_ENDPOINT",
"identityServiceEndpoint": "IDENTITY_SERVICE_ENDPOINT",
"memberServiceEndpoint": "MEMBER_SERVICE_ENDPOINT",
"systemUserClientId": "SYSTEM_USER_CLIENT_ID",
"systemUserClientSecret": "SYSTEM_USER_CLIENT_SECRET",
"connectProjectsUrl": "CONNECT_PROJECTS_URL",
"dbConfig": {
"masterUrl": "DB_MASTER_URL",
Expand Down
2 changes: 0 additions & 2 deletions config/default.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@
"timelineIndexName": "timelines",
"timelineDocType": "timelineV4"
},
"systemUserClientId": "",
"systemUserClientSecret": "",
"connectProjectUrl":"",
"dbConfig": {
"masterUrl": "",
Expand Down
4 changes: 2 additions & 2 deletions src/events/projectMembers/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ const projectMemberAddedHandler = Promise.coroutine(function* a(logger, msg, cha
// add copilot/update manager permissions operation promise
const directProjectId = yield models.Project.getDirectProjectId(projectId);
if (directProjectId) {
const token = yield util.getSystemUserToken(logger);
const token = yield util.getM2MToken();
const req = {
id: origRequestId,
log: logger,
Expand Down Expand Up @@ -119,7 +119,7 @@ const projectMemberRemovedHandler = Promise.coroutine(function* (logger, msg, ch
if (_.indexOf([PROJECT_MEMBER_ROLE.COPILOT, PROJECT_MEMBER_ROLE.MANAGER], member.role) > -1) {
const directProjectId = yield models.Project.getDirectProjectId(projectId);
if (directProjectId) {
const token = yield util.getSystemUserToken(logger);
const token = yield util.getM2MToken();
const req = {
id: origRequestId,
log: logger,
Expand Down
4 changes: 0 additions & 4 deletions src/services/messageService.js
Original file line number Diff line number Diff line change
Expand Up @@ -65,12 +65,8 @@ async function getClient(logger) {
function createTopic(topic, logger) {
logger.debug(`createTopic for topic: ${JSON.stringify(topic)}`);
return getClient(logger).then((msgClient) => {
// return util.getSystemUserToken(logger).then((adminToken) => {
logger.debug('calling message service');
return msgClient.post('/topics/create', topic)
// const httpClient = util.getHttpClient({ id: `topic#create#${topic.referenceId}`, log: logger });
// httpClient.defaults.headers.common.Authorization = `Bearer ${adminToken}`;
// return httpClient.post(`${config.get('messageApiUrl')}/topics/create`, topic)
.then((resp) => {
logger.debug('Topic created successfully');
logger.debug(`Topic created successfully [status]: ${resp.status}`);
Expand Down
14 changes: 0 additions & 14 deletions src/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -261,20 +261,6 @@ _.assignIn(util, {
});
},

getSystemUserToken: (logger, id = 'system') => {
const httpClient = util.getHttpClient({ id, log: logger });
const url = `${config.get('identityServiceEndpoint')}authorizations`;
const formData = `clientId=${config.get('systemUserClientId')}&` +
`secret=${encodeURIComponent(config.get('systemUserClientSecret'))}`;
return httpClient.post(url, formData,
{
timeout: 4000,
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
},
)
.then(res => res.data.result.content.token);
},

/**
* Get machine to machine token.
* @returns {Promise} promise which resolves to the m2m token
Expand Down