Skip to content
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

Reintroduce express to proxy to rails app #4225

Merged
merged 7 commits into from
Oct 2, 2023
Merged

Conversation

tsmartt
Copy link
Contributor

@tsmartt tsmartt commented Sep 28, 2023

This express proxy will take care of rewriting redirects coming back from rails which will redirect to itself. We want instead to redirect back to our Next proxy.

@tsmartt tsmartt marked this pull request as ready for review October 2, 2023 19:59
onProxyRes: (proxyRes, request, response) => {
const redir = proxyRes.headers['location'];
if (redir) {
const host = parse(redir).host;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Avoid using url.parse() as it may cause security issues. Consider using the URL class instead.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/nodejs-insecure-url-parse.yaml


Cc @thypon @fmarier

const host = parse(redir).host;
if (`https://${host}` == pubHost) {
const newRedirUrlToProxy = `${nextHost}${
parse(redir).pathname
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] Avoid using url.parse() as it may cause security issues. Consider using the URL class instead.

Source: https://github.com/brave/security-action/blob/main/assets/semgrep_rules/services/nodejs-insecure-url-parse.yaml


Cc @thypon @fmarier

app
.prepare()
.then(() => {
const expressApp = express();
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reported by reviewdog 🐶
[semgrep] A CSRF middleware was not detected in your express application. Ensure you are either using one such as csurf or csrf (see rule references) and/or you are properly doing CSRF validation in your routes with a token or cookies.

Source: https://semgrep.dev/r/javascript.express.security.audit.express-check-csurf-middleware-usage.express-check-csurf-middleware-usage


Cc @thypon @bcaller

@thypon
Copy link
Collaborator

thypon commented Oct 2, 2023

Is there any flow diagram of the next/rails forwarding?

Cc @bcaller

Copy link
Contributor

@mattwilliams85 mattwilliams85 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
Looks good to me!

@tsmartt tsmartt merged commit f8f9b98 into staging Oct 2, 2023
7 checks passed
@tsmartt tsmartt deleted the feat/reintro-express branch October 2, 2023 20:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants