Skip to content

feat: use token when calling DC #646

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 2 commits into from
Sep 22, 2023
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
4 changes: 3 additions & 1 deletion src/common/m2m-helper.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@ class M2MHelper {
static m2m = null;

constructor() {
M2MHelper.m2m = m2mAuth(_.pick(config, ["AUTH0_URL", "AUTH0_AUDIENCE", "TOKEN_CACHE_TIME"]));
M2MHelper.m2m = m2mAuth(
_.pick(config, ["AUTH0_URL", "AUTH0_AUDIENCE", "TOKEN_CACHE_TIME", "AUTH0_PROXY_SERVER_URL"])
);
}
/**
* Get M2M token.
Expand Down
3 changes: 3 additions & 0 deletions src/services/ChallengeService.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ const {
convertToISOString,
} = require("../common/challenge-helper");
const deepEqual = require("deep-equal");
const { getM2MToken } = require("../common/m2m-helper");

const challengeDomain = new ChallengeDomain(GRPC_CHALLENGE_SERVER_HOST, GRPC_CHALLENGE_SERVER_PORT);
const phaseAdvancer = new PhaseAdvancer(challengeDomain);
Expand Down Expand Up @@ -1027,6 +1028,7 @@ async function createChallenge(currentUser, challenge, userToken) {

grpcMetadata.set("handle", currentUser.handle);
grpcMetadata.set("userId", currentUser.userId);
grpcMetadata.set("token", await getM2MToken());

convertPrizeSetValuesToCents(challenge.prizeSets);
const ret = await challengeDomain.create(challenge, grpcMetadata);
Expand Down Expand Up @@ -1791,6 +1793,7 @@ async function updateChallenge(currentUser, challengeId, data) {

grpcMetadata.set("handle", currentUser.handle);
grpcMetadata.set("userId", currentUser.userId);
grpcMetadata.set("token", await getM2MToken());

if (updateInput.prizeSetUpdate != null) {
convertPrizeSetValuesToCents(updateInput.prizeSetUpdate.prizeSets);
Expand Down