-
Notifications
You must be signed in to change notification settings - Fork 16
add: url signing for onramper widget #517
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -795,6 +795,29 @@ const setup = (app: Router, verifier: VerificationAPI, storage: StorageAPI) => { | |
| }) | ||
| ) | ||
|
|
||
| app.post( | ||
| '/verify/onramper/sign', | ||
| requestRateLimiter(20, 1), | ||
| passport.authenticate(['jwt', 'anonymous'], { session: false }), | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🚨 issue (security): Allowing the With Require a strictly authenticated strategy (e.g.
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @L03TJ3 |
||
| wrapAsync(async (req, res) => { | ||
| const { log, body = {} } = req | ||
| const { signContent } = body | ||
|
|
||
| if (!signContent || typeof signContent !== 'string') { | ||
| return res.status(400).json({ ok: -1, error: 'missing signContent' }) | ||
| } | ||
|
|
||
| if (!conf.onramperUrlSigningSecret) { | ||
| log.error('onramper sign request failed, missing ONRAMPER_URL_SIGNING_SECRET') | ||
| return res.status(500).json({ ok: -1, error: 'Onramper signing secret is not configured' }) | ||
| } | ||
|
|
||
| const signature = crypto.createHmac('sha256', conf.onramperUrlSigningSecret).update(signContent).digest('hex') | ||
|
|
||
| return res.json({ ok: 1, signContent, signature }) | ||
| }) | ||
| ) | ||
|
|
||
| /** | ||
| * @api {post} /verify/email Send verification email endpoint | ||
| * @apiName Send Email | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
suggestion (testing): Add a test case for non-string
signContentto cover the type check branch.The case where
signContentis present but not a string (typeof signContent !== 'string') isn’t currently tested. Please add a test (e.g.send({ signContent: { foo: 'bar' } })or a number/array) and assert it returns the same 400 response, so the type guard branch is covered and protected against regressions.