Skip to content

Commit

Permalink
Remove Python2 support
Browse files Browse the repository at this point in the history
  • Loading branch information
Briar Scott committed Mar 25, 2021
1 parent 6d83b95 commit 732d384
Show file tree
Hide file tree
Showing 7 changed files with 22 additions and 34 deletions.
11 changes: 6 additions & 5 deletions .github/workflows/python-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand All @@ -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
run: flask routes
24 changes: 8 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.

Expand All @@ -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 <test_name>.py
# Run all tests with nose
nose2
python3 <test_name>.py
# Run all tests with unittest
python -m unittest
python3 -m unittest
```

## Lint
Expand Down
13 changes: 4 additions & 9 deletions demo/README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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.
Expand All @@ -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).
Expand Down
2 changes: 1 addition & 1 deletion duo_universal/client.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from six.moves.urllib.parse import urlencode
from urllib.parse import urlencode
import time
import jwt
import requests
Expand Down
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
1 change: 0 additions & 1 deletion tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
mock>=3.0.5
nose2>=0.9.1
flake8>=3.7.9
dlint>=0.9.2
2 changes: 1 addition & 1 deletion tests/test_create_auth.py
Original file line number Diff line number Diff line change
@@ -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
Expand Down

0 comments on commit 732d384

Please sign in to comment.