Skip to content

Commit

Permalink
add more logs
Browse files Browse the repository at this point in the history
  • Loading branch information
pnedelko committed Aug 22, 2023
1 parent 83ffa31 commit 230e002
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
7 changes: 5 additions & 2 deletions services/secret-service/src/auth-flow-manager/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ const { OA2_AUTHORIZATION_CODE, OA1_THREE_LEGGED, SESSION_AUTH } = require('../c
const { HEADER_AUTH, BODY_AUTH, PARAMS_AUTH } = require('../constant').AUTH_REQUEST_TYPE;
const defaultAdapter = require('../adapter/preprocessor/default');

const log = logger.getLogger(`${conf.log.namespace}/auth-flow-manager`);
const log = logger.getLogger(`${conf.log.namespace}/auth-flow-manager`, { json: true });

class HTTPResponseError extends Error {
constructor(response, ...args) {
Expand Down Expand Up @@ -240,7 +240,10 @@ module.exports = {
}
},
async refresh(authClient, secret) {
log.debug(`Refreshing auth ${secret && secret._id ? secret._id : ''} client id: ${authClient && authClient._id ? authClient._id : ''}`);
log.debug(`Refreshing secret ${secret && secret._id ? secret._id : ''} via auth client id: ${authClient && authClient._id ? authClient._id : ''}`, {
secretId: secret._id,
authClientId: authClient._id
});
switch (authClient.type) {
case OA2_AUTHORIZATION_CODE: {
const { clientId, clientSecret, refreshWithScope } = authClient;
Expand Down
4 changes: 4 additions & 0 deletions services/secret-service/src/dao/secret.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ const CONSTANTS = require('../constant');

const auditLog = Logger.getAuditLogger(`${conf.log.namespace}/secretDao`);

const log = Logger.getLogger(`${conf.log.namespace}/secretDao`, { json: true });

// retry refresh procedure after ms
const waitBeforeRetry = 1000;
const MAX_RETRY = 3;
Expand Down Expand Up @@ -72,11 +74,13 @@ function refreshToken(secret) {
try {
const authClient = await AuthClientDAO.findById(secret.value.authClientId);

log.debug('About to refresh secret', { secretId: secret._id, authClientId: authClient._id });
resolve(await authFlowManager.refresh(
authClient,
secret,
));
} catch (err) {
log.error('Failed to refresh secret', { secretId: secret._id, authClientId: authClient._id, err });
reject(err);
}
});
Expand Down

0 comments on commit 230e002

Please sign in to comment.