-
-
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 3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -49,6 +49,36 @@ | |
ALTERNATIVE_HISTNORM = 'probability' | ||
|
||
|
||
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 " | ||
"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-Prem 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-Prem." | ||
) | ||
|
||
|
||
def validate_config_file(*domains): | ||
for d in domains: | ||
if not d.lower().startswith('https'): | ||
warnings.warn(http_msg) | ||
|
||
|
||
# Warning format | ||
def warning_on_one_line(message, category, filename, lineno, | ||
file=None, line=None): | ||
|
@@ -194,6 +224,7 @@ def set_config_file(plotly_domain=None, | |
'sharing': sharing, 'world_readable': world_readable}) | ||
settings = get_config_file() | ||
if isinstance(plotly_domain, six.string_types): | ||
validate_config_file(plotly_domain) | ||
settings['plotly_domain'] = plotly_domain | ||
elif plotly_domain is not None: | ||
raise TypeError('plotly_domain should be a string') | ||
|
@@ -202,6 +233,7 @@ def set_config_file(plotly_domain=None, | |
elif plotly_streaming_domain is not None: | ||
raise TypeError('plotly_streaming_domain should be a string') | ||
if isinstance(plotly_api_domain, six.string_types): | ||
validate_config_file(plotly_api_domain) | ||
settings['plotly_api_domain'] = plotly_api_domain | ||
elif plotly_api_domain is not None: | ||
raise TypeError('plotly_api_domain should be a string') | ||
|
@@ -244,9 +276,10 @@ def get_config_file(*args): | |
""" | ||
if check_file_permissions(): | ||
ensure_local_plotly_files() # make sure what's there is OK | ||
return utils.load_json_dict(CONFIG_FILE, *args) | ||
returned_obj = utils.load_json_dict(CONFIG_FILE, *args) | ||
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 commentThe 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? |
||
|
||
|
||
def reset_config_file(): | ||
|
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.
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