From 732d3843eb00ce2ba6b740a41e22ed5c9342631f Mon Sep 17 00:00:00 2001 From: Briar Scott Date: Thu, 25 Mar 2021 11:21:44 -0400 Subject: [PATCH] Remove Python2 support --- .github/workflows/python-ci.yml | 11 ++++++----- README.md | 24 ++++++++---------------- demo/README.md | 13 ++++--------- duo_universal/client.py | 2 +- setup.py | 3 ++- tests/requirements.txt | 1 - tests/test_create_auth.py | 2 +- 7 files changed, 22 insertions(+), 34 deletions(-) diff --git a/.github/workflows/python-ci.yml b/.github/workflows/python-ci.yml index 9e97648..3fcb4b6 100644 --- a/.github/workflows/python-ci.yml +++ b/.github/workflows/python-ci.yml @@ -7,7 +7,7 @@ jobs: strategy: matrix: - python-version: [2.7, 3.6, 3.7, 3.8, 3.9] + python-version: [3.6, 3.7, 3.8, 3.9] steps: - uses: actions/checkout@v2 @@ -17,12 +17,13 @@ jobs: python-version: ${{ matrix.python-version }} - name: Dependencies run: | - pip install -r requirements.txt + pip install . pip install -r tests/requirements.txt - name: Lint with flake8 run: flake8 - - name: Test with nose2 - run: nose2 + - name: Test with Python3 + working-directory: tests + run: python3 -m unittest - name: Demo dependencies working-directory: demo run: pip install -r requirements.txt @@ -31,4 +32,4 @@ jobs: run: printf "[duo]\nclient_id=DIAAAAAAAAAAAAAAAAAA\nclient_secret=AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA\napi_hostname=example.duosecurity.com\nredirect_uri=http://localhost:8080\nfailmode=closed\n" > ./duo.conf - name: Verify flask can load demo working-directory: demo - run: flask routes \ No newline at end of file + run: flask routes diff --git a/README.md b/README.md index 5062161..ccfeb28 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ [![License](https://img.shields.io/badge/License-View%20License-orange)](https://github.com/duosecurity/duo_universal_python/blob/master/LICENSE) -This SDK allows a web developer to quickly add Duo's interactive, self-service, two-factor authentication to any Python web login form. Both Python 2 and Python 3 are supported. +This SDK allows a web developer to quickly add Duo's interactive, self-service, two-factor authentication to any Python3 web login form. Only Python 3 is supported. What's here: * `duo_universal` - The Python Duo SDK for interacting with the Duo Universal Prompt @@ -17,7 +17,7 @@ What's here: ## Getting Started To use the SDK in your existing development environment, install it from pypi (https://pypi.org/project/duo_universal). ``` -pip install duo_universal +pip3 install duo_universal ``` Once it's installed, see our developer documentation at https://duo.com/docs/duoweb and `demo/app.py` in this repo for guidance on integrating Duo 2FA into your web application. @@ -26,37 +26,29 @@ To contribute, fork this repo and make a pull request with your changes when the If you're not already working from a dedicated development environment, it's recommended a virtual environment is used. Assuming a virtual environment named `env`, create and activate the environment: ``` -# Python 3 -python -m venv env -source env/bin/activate - -# Python 2 -virtualenv env +python3 -m venv env source env/bin/activate ``` Build and install the SDK from source: ``` -pip install -r requirements.txt -pip install . +pip3 install -r requirements.txt +pip3 install . ``` ## Tests Install the test requirements: ``` cd tests -pip install -r requirements.txt +pip3 install -r requirements.txt ``` Then run tests from the `test` directory: ``` # Run an individual test file -python .py - -# Run all tests with nose -nose2 +python3 .py # Run all tests with unittest -python -m unittest +python3 -m unittest ``` ## Lint diff --git a/demo/README.md b/demo/README.md index 70a7739..ad1b81c 100644 --- a/demo/README.md +++ b/demo/README.md @@ -1,6 +1,6 @@ # Duo Universal Python SDK Demo -A simple Python web application that serves a logon page integrated with Duo 2FA. +A simple Python3 web application that serves a logon page integrated with Duo 2FA. ## Setup Change to the "demo" directory @@ -10,18 +10,13 @@ cd demo Set up a virtual environment ``` -# Python 3 -python -m venv env -source env/bin/activate - -# Python 2 -virtualenv env +python3 -m venv env source env/bin/activate ``` Install the demo requirements: ``` -pip install -r requirements.txt +pip3 install -r requirements.txt ``` Then, create a `Web SDK` application in the Duo Admin Panel. See https://duo.com/docs/protecting-applications for more details. @@ -31,7 +26,7 @@ Then, create a `Web SDK` application in the Duo Admin Panel. See https://duo.com 1. Copy the Client ID, Client Secret, and API Hostname values for your `Web SDK` application into the `duo.conf` file. 1. Start the app. ``` - python app.py + python3 app.py ``` 1. Navigate to http://localhost:8080. 1. Log in with the user you would like to enroll in Duo or with an already enrolled user (any password will work). diff --git a/duo_universal/client.py b/duo_universal/client.py index 6583fc1..5c3f7b3 100644 --- a/duo_universal/client.py +++ b/duo_universal/client.py @@ -1,4 +1,4 @@ -from six.moves.urllib.parse import urlencode +from urllib.parse import urlencode import time import jwt import requests diff --git a/setup.py b/setup.py index b39f94f..2aa73ce 100644 --- a/setup.py +++ b/setup.py @@ -48,8 +48,9 @@ def get_version(rel_path): description='Duo Web SDK for two-factor authentication', long_description=long_description, long_description_content_type='text/markdown', + python_requires='>=3', classifiers=[ - 'Programming Language :: Python', + 'Programming Language :: Python :: 3', 'License :: OSI Approved :: BSD License' ], install_requires=install_requires, diff --git a/tests/requirements.txt b/tests/requirements.txt index cb7c24a..09e5f6f 100644 --- a/tests/requirements.txt +++ b/tests/requirements.txt @@ -1,4 +1,3 @@ mock>=3.0.5 -nose2>=0.9.1 flake8>=3.7.9 dlint>=0.9.2 diff --git a/tests/test_create_auth.py b/tests/test_create_auth.py index 3c73748..1887620 100644 --- a/tests/test_create_auth.py +++ b/tests/test_create_auth.py @@ -1,4 +1,4 @@ -from six.moves.urllib.parse import urlencode +from urllib.parse import urlencode from duo_universal import client from mock import MagicMock, patch import jwt