-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
validate plotly_(api)_domain - HTTPS, not HTTP #997
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
Conversation
Thanks @Kully! @Kully @cldougl what do y'all think of approaching this fix as a validation on the Perhaps a helper function like |
I like this approach. What about we have both just in case? I don't know why the helper function could be bypassed if we set it up correctly though |
I think the validation will be sufficient, personally! |
Yep I think the config validation could be more beneficial for the user. |
@Kully I think this should just be issued as a warning for now and not a full error. Though SSL/TLS is now required for On-Prem, there are some clients that still may be running older versions without SSL/TLS enabled. |
@BRONSOLO I've deleted the error msg and made a warning instead. I only placed the There is the possibility of added a I personally think that we need to validate |
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.
Thanks @Kully! Could you please add a test for these changes?
plotly/tools.py
Outdated
else: | ||
return FILE_CONTENT[CONFIG_FILE] | ||
returned_obj = FILE_CONTENT[CONFIG_FILE] | ||
return returned_obj |
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.
Is this change necessary? Could you add it to a separate commit with a commit msg that explains why if so?
plotly/tools.py
Outdated
) | ||
|
||
|
||
def validate_config_file(*domains): |
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.
This is really just validating domains - what do you think about renaming this as validate_domains
?
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.
good idea
notes:
Waiting for tests to pass. |
Looks like only streaming errors. We are ignoring these for now @cldougl ? |
@Kully, the streaming tests should pass now |
plotly/tools.py
Outdated
@@ -186,12 +186,14 @@ def set_config_file(plotly_domain=None, | |||
:param (bool) world_readable: True = public, False = private | |||
|
|||
""" | |||
# import ipdb; ipdb.set_trace() |
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.
please remove this commented code as it is unnecessary 🔪 : )
@@ -297,6 +322,7 @@ def encode_as_decimal(obj): | |||
else: | |||
raise NotEncodable | |||
|
|||
|
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.
Is this line needed?
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.
it keeps the file consistent with 2 spaces between functions
@Kully could you please provide a screenshot of what that warning message looks like when hit? |
plotly/utils.py
Outdated
@@ -32,6 +33,30 @@ | |||
lock = threading.Lock() | |||
|
|||
|
|||
http_msg = ( | |||
"The plotly_domain and plotly_api_domain of your config file must start " | |||
"with 'https', 'http'.\n If you are not using On-Prem then run the " |
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.
Why include http
here? ---> "with 'https', 'http'.
Also I would suggest using On-Premise
instead of On-Prem
to be consistent with the rest of the codebase.
Also, this .\n If...
is introducing an unnecessary space at the start of the line that could be cleaned up.
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.
That was a typo. I meant to type 'https', not 'http'
. Is it fine like that?
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.
Yep! Thanks.
plotly/utils.py
Outdated
" plotly_domain='https://plot.ly',\n" | ||
" plotly_api_domain='https://api.plot.ly'\n" | ||
")\n\n\n" | ||
"If you are using On-Prem then you will need to use your company's " |
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.
same here On-Prem
---> On-Premise
plotly/utils.py
Outdated
"Make sure to replace `your-company.com` with the URL of your Plotly " | ||
"On-Premise server.\nSee " | ||
"https://plot.ly/python/getting-started/#special-instructions-for-plotly-onpremise-users " | ||
"for more help with getting started with On-Prem." |
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.
Same here.
assert len(w) == 1 | ||
assert issubclass(w[-1].category, UserWarning) | ||
assert "plotly_domain" in str(w[-1].message) | ||
|
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.
Nice! Could you also include a test to check that no warning is issued when https
is used?
@BRONSOLO all comments addressed. Waiting for tests again. |
yay tests are passing 🎉 |
plotly/utils.py
Outdated
@@ -35,15 +35,15 @@ | |||
|
|||
http_msg = ( | |||
"The plotly_domain and plotly_api_domain of your config file must start " | |||
"with 'https', 'http'.\n If you are not using On-Prem then run the " | |||
"with 'https', not 'http'.\n If you are not using On-Premise then run the " |
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 believe the \n If
... spacing still needs to be fixed. I think it would look cleaner without a new line actually.
One small comment and then 💃 after that. |
Addresses #996
Notes:
zhttp://...
. A separate error message is thrown for that.