Skip to content

Commit 12d375a

Browse files
aoncalvogenerico
andauthored
fix: secret parsing whitelisting private rpc (#4347)
## What ❔ Fix a mismatch between secret sending between `private-rpc` and `block-explorer`. Currently the `block-explorer` sends the secret in the header: https://github.com/matter-labs/block-explorer/blob/prividium-mode/packages/api/src/auth/auth.controller.ts#L227. The mismatch was ocurring due to `private-rpc` sending it as a query param. <!-- What are the changes this PR brings about? --> <!-- Example: This PR adds a PR template to the repo. --> <!-- (For bigger PRs adding more context is appreciated) --> ## Why ❔ <!-- Why are these changes done? What goal do they contribute to? What are the principles behind them? --> <!-- The `Why` has to be clear to non-Matter Labs entities running their own ZK Chain --> <!-- Example: PR templates ensure PR reviewers, observers, and future iterators are in context about the evolution of repos. --> ## Is this a breaking change? - [ ] Yes - [ ] No ## Operational changes <!-- Any config changes? Any new flags? Any changes to any scripts? --> <!-- Please add anything that non-Matter Labs entities running their own ZK Chain may need to know --> ## Checklist <!-- Check your PR fulfills the following items. --> <!-- For draft PRs check the boxes as you complete them. --> - [ ] PR title corresponds to the body of PR (we generate changelog entries from PRs). - [ ] Tests for the changes have been added / updated. - [ ] Documentation comments have been added / updated. - [ ] Code has been formatted via `zkstack dev fmt` and `zkstack dev lint`. --------- Co-authored-by: calvo.generico <[email protected]>
1 parent 7ba2cf3 commit 12d375a

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

private-rpc/src/routes/users-routes.ts

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,16 @@ export function usersRoutes(app: WebServer) {
4646
schema: {
4747
params: z.object({
4848
address: addressSchema
49-
}),
50-
querystring: z.object({
51-
secret: z.string()
5249
})
5350
}
5451
};
5552

5653
app.get('/:address', getUserSchema, (req, reply) => {
5754
const { authorizer, createTokenSecret } = app.context;
58-
const { secret } = req.query;
55+
const secret = req.headers['x-secret'];
5956

6057
if (secret !== createTokenSecret) {
58+
console.warn(`Invalid secret sent: ${secret}`);
6159
throw new HttpError('forbidden', 403);
6260
}
6361

0 commit comments

Comments
 (0)