-
-
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
Merged
Merged
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
a9f0c95
error message that catches responses with HTTP and not HTTPS
Kully 556ef45
make sure history is not an empty list
Kully 6b12bf2
made a warning instead
Kully 0c189f2
changed validate_config_file to validate_domains
Kully 6e4622c
refactor get_config_file guts so returned_objs is validated after gra…
Kully c063f23
validation warning can be triggered on get_config and set_config
Kully fe31851
started on tests
Kully e55e81c
moved validation function to utils//test working
Kully efc36a2
removed commented line
Kully 46d3cc9
chuck's requestsed changes from review
Kully 2a0872c
remove \n from msg
Kully File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,11 +7,12 @@ | |
""" | ||
from __future__ import absolute_import | ||
|
||
import decimal | ||
import os.path | ||
import re | ||
import sys | ||
import threading | ||
import decimal | ||
import warnings | ||
from collections import deque | ||
|
||
import pytz | ||
|
@@ -32,6 +33,30 @@ | |
lock = threading.Lock() | ||
|
||
|
||
http_msg = ( | ||
"The plotly_domain and plotly_api_domain of your config file must start " | ||
"with 'https', not 'http'. If you are not using On-Premise then run the " | ||
"following code to ensure your plotly_domain and plotly_api_domain start " | ||
"with 'https':\n\n\n" | ||
"import plotly\n" | ||
"plotly.tools.set_config_file(\n" | ||
" plotly_domain='https://plot.ly',\n" | ||
" plotly_api_domain='https://api.plot.ly'\n" | ||
")\n\n\n" | ||
"If you are using On-Premise then you will need to use your company's " | ||
"domain and api_domain urls:\n\n\n" | ||
"import plotly\n" | ||
"plotly.tools.set_config_file(\n" | ||
" plotly_domain='https://plotly.your-company.com',\n" | ||
" plotly_api_domain='https://plotly.your-company.com'\n" | ||
")\n\n\n" | ||
"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-Premise." | ||
) | ||
|
||
|
||
### general file setup tools ### | ||
|
||
def load_json_dict(filename, *args): | ||
|
@@ -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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. it keeps the file consistent with 2 spaces between functions |
||
### unicode stuff ### | ||
def decode_unicode(coll): | ||
if isinstance(coll, list): | ||
|
@@ -436,6 +462,16 @@ def validate_world_readable_and_sharing_settings(option_set): | |
) | ||
|
||
|
||
def validate_plotly_domains(option_set): | ||
domains_not_none = [] | ||
for d in ['plotly_domain', 'plotly_api_domain']: | ||
if d in option_set and option_set[d]: | ||
domains_not_none.append(option_set[d]) | ||
|
||
if not all(d.lower().startswith('https') for d in domains_not_none): | ||
warnings.warn(http_msg, category=UserWarning) | ||
|
||
|
||
def set_sharing_and_world_readable(option_set): | ||
if 'world_readable' in option_set and 'sharing' not in option_set: | ||
option_set['sharing'] = ( | ||
|
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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?