Skip to content
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: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
Dash Authorization Package

[![CircleCI](https://circleci.com/gh/plotly/dash-auth.svg?style=svg)](https://circleci.com/gh/plotly/dash-auth)
3 changes: 2 additions & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
machine:
post:
- pyenv global 2.7.10 3.4.3 3.5.0
- pyenv global 2.7.10 3.3.6 3.4.4 3.5.3 3.6.2
environment:
TOX_PYTHON_27: python2.7
TOX_PYTHON_33: python3.3
TOX_PYTHON_34: python3.4
TOX_PYTHON_35: python3.5
TOX_PYTHON_36: python3.6


dependencies:
Expand Down
5 changes: 3 additions & 2 deletions dash_auth/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
from plotly_auth import PlotlyAuth
from basic_auth import BasicAuth
from __future__ import absolute_import
from .plotly_auth import PlotlyAuth
from .basic_auth import BasicAuth
1 change: 1 addition & 0 deletions dash_auth/api_requests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import
import copy
import os
import plotly
Expand Down
9 changes: 5 additions & 4 deletions dash_auth/auth.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@

from __future__ import absolute_import
from abc import ABCMeta, abstractmethod
import flask
from six import iteritems
from six import iteritems, add_metaclass


@add_metaclass(ABCMeta)
class Auth(object):
__metaclass__ = ABCMeta

def __init__(self, app):
self.app = app
self._overwrite_index()
Expand All @@ -24,7 +25,7 @@ def wrap_index(*args, **kwargs):

def _protect_views(self):
# TODO - allow users to white list in case they add their own views
for view_name, view_method in self.app.server.view_functions.iteritems():
for view_name, view_method in iteritems(self.app.server.view_functions):
if view_name != 'index':
self.app.server.view_functions[view_name] = \
self.auth_wrapper(view_method)
Expand Down
2 changes: 1 addition & 1 deletion dash_auth/basic_auth.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from auth import Auth
from .auth import Auth
import base64
import flask

Expand Down
5 changes: 3 additions & 2 deletions dash_auth/plotly_auth.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
from __future__ import absolute_import
import datetime
import flask
from flask_seasurf import SeaSurf
import json
import os
from six import iteritems
from auth import Auth
from .auth import Auth

import api_requests
from . import api_requests

AUTH_COOKIE_NAME = 'plotly_auth'

Expand Down
2 changes: 1 addition & 1 deletion dev-requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
dash_core_components
dash_html_components
dash_renderer
dash
dash==0.17.8rc2
percy
selenium
mock
Expand Down
8 changes: 6 additions & 2 deletions tests/IntegrationTests.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import
from selenium import webdriver
from selenium.webdriver.common.keys import Keys
import importlib
Expand All @@ -20,9 +21,12 @@ def setUp(self):
pass

def tearDown(self):
time.sleep(2)
time.sleep(3)
self.server_process.terminate()
time.sleep(2)
time.sleep(3)

if hasattr(self, 'driver'):
self.driver.quit()


def startServer(self, app):
Expand Down
12 changes: 5 additions & 7 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@
import dash
import dash_html_components as html
import dash_core_components as dcc
from IntegrationTests import IntegrationTests
from utils import assert_clean_console, invincible, switch_windows, wait_for
from users import users
from dash_auth import plotly_auth
from multiprocessing import Value
import os
import time
Expand All @@ -14,6 +10,11 @@
import plotly.plotly as py
from selenium import webdriver

from IntegrationTests import IntegrationTests
from utils import assert_clean_console, invincible, switch_windows, wait_for
from users import users
from dash_auth import plotly_auth


class Tests(IntegrationTests):
def setUp(self):
Expand All @@ -33,9 +34,6 @@ def wait_for_element_by_css_selector(css_selector):
self.wait_for_element_by_css_selector = wait_for_element_by_css_selector


def tearDown(self):
self.driver.quit()

def login_flow(self, username, pw):
os.environ['PLOTLY_USERNAME'] = users['creator']['username']
os.environ['PLOTLY_API_KEY'] = users['creator']['api_key']
Expand Down
5 changes: 3 additions & 2 deletions tests/test_plotlyauth.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
from __future__ import absolute_import
import time
import unittest
import dash
Expand Down Expand Up @@ -55,7 +56,7 @@ def get_cookie(res, cookie_name):
def create_apps():
app_permissions = ['public', 'private']
apps = {k: dash.Dash(k) for k in app_permissions}
for app in apps.values():
for app in list(apps.values()):
app.scripts.config.serve_locally = True
auths = {
k: PlotlyAuth(
Expand Down Expand Up @@ -152,7 +153,7 @@ def get_client():

def test_protected_endpoints_with_auth_cookie(self):
apps, auths = create_apps()
for user_attributes in users.values():
for user_attributes in list(users.values()):
for app_name, app in iteritems(apps):
if app_name != 'unregistered':
app.layout = html.Div()
Expand Down
6 changes: 4 additions & 2 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@ envlist = py27,py33,py34,py35

[testenv]
deps = -rdev-requirements.txt
passenv=TOX_*
passenv =
HOME
DISPLAY

[testenv:py27]
basepython={env:TOX_PYTHON_35}
basepython={env:TOX_PYTHON_27}
commands =
python --version
python -m unittest discover -s tests/
Expand Down