-
Notifications
You must be signed in to change notification settings - Fork 84
Support restricting device connections to the web endpoint #1881
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: main
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 |
|---|---|---|
| @@ -1,12 +1,19 @@ | ||
| defmodule NervesHub.Helpers.WebsocketConnectionError do | ||
| import Plug.Conn | ||
|
|
||
| @message "no certificate pair or shared secrets connection settings were provided" | ||
| @no_auth_message "no certificate pair or shared secrets connection settings were provided" | ||
| @check_uri_message "incorrect uri used, please contact support" | ||
|
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. can we get some configured URL info into this message so we can actually tell them the fix?
Collaborator
Author
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. Sure. Although, just so you know, slipstream doesn't show this message by default, which is a pity |
||
|
|
||
| def handle_error(conn, :no_auth) do | ||
| conn | ||
| |> put_resp_header("nh-connection-error-reason", @message) | ||
| |> send_resp(401, @message) | ||
| |> put_resp_header("nh-connection-error-reason", @no_auth_message) | ||
| |> send_resp(401, @no_auth_message) | ||
| end | ||
|
|
||
| def handle_error(conn, :check_uri) do | ||
| conn | ||
| |> put_resp_header("nh-connection-error-reason", @check_uri_message) | ||
| |> send_resp(404, @check_uri_message) | ||
| end | ||
|
|
||
| def handle_error(conn, _reason), do: send_resp(conn, 401, "") | ||
|
|
||
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.
I wonder if we should have an in-between mode for the transition that just throws a "wrong-endpoint" key in the device connection metadata or similar. And then we could show it to people.
Though we have few enough people that will be hit by it that we can essentially tell them and give them a deadline?
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.
Yeah, I wouldn't want to add too much extra complexity to this. Instead we can just send out a warning to current users, check our logs to make sure people are off, and then turn it off. I have no intention to turn this off yet.