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

chore(bot): constrain HTTP Get for public folder #1225

Merged
merged 1 commit into from
May 28, 2021
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
2 changes: 1 addition & 1 deletion templates/bot-msgext/js/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ server.post("/api/messages", async (req, res) => {
});

server.get(
"/*",
/auth-start\.html|auth-end\.html/,
Copy link
Contributor

Choose a reason for hiding this comment

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

In fact, I don't quite understand this problem. Since it is the public folder, why we limits the access. Don't we provide any js file on the website?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think the issue is that the error message contains the info outside of the public folder. So do we really fix it in this way?

Copy link
Contributor

Choose a reason for hiding this comment

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

If we really only need to provide the two path on the website, I think it is ok.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the comments. To provide context, the public folder contains only two html files, as you can guess what they are, for the authentication flow. The former scope of the Get was too broader, that is all Get requests will be redirected into the public folder, but we only want to serve just two specific html files.
After the route is limited, any other request will get an HTTP 500 Code, no inner path will be exposed.

restify.plugins.serveStatic({
directory: path.join(__dirname, "public"),
})
Expand Down
2 changes: 1 addition & 1 deletion templates/bot-msgext/ts/default/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ server.post("/api/messages", async (req, res) => {
});

server.get(
"/*",
/auth-start\.html|auth-end\.html/,
restify.plugins.serveStatic({
directory: path.join(__dirname, "public"),
})
Expand Down
2 changes: 1 addition & 1 deletion templates/bot/js/default/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ server.post("/api/messages", async (req, res) => {
});

server.get(
"/*",
/auth-start\.html|auth-end\.html/,
restify.plugins.serveStatic({
directory: path.join(__dirname, "public"),
})
Expand Down
2 changes: 1 addition & 1 deletion templates/bot/ts/default/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ server.post("/api/messages", async (req, res) => {
});

server.get(
"/*",
/auth-start\.html|auth-end\.html/,
restify.plugins.serveStatic({
directory: path.join(__dirname, "public"),
})
Expand Down