GithubHelp home page GithubHelp logo

duosecurity / duo_universal_python Goto Github PK

View Code? Open in Web Editor NEW
21.0 31.0 21.0 89 KB

Duo OIDC-based two-factor authentication for Python web applications

Home Page: https://duo.com/docs/duoweb

License: Other

Python 99.30% Shell 0.70%
duo mfa python

duo_universal_python's Introduction

Duo Universal Python SDK

Build Status Issues Forks Stars License

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.

Tested Against Python Versions:

  • 3.7
  • 3.8
  • 3.9
  • 3.10
  • 3.11

TLS 1.2 and 1.3 Support

Duo_universal_python uses Python's ssl module and OpenSSL for TLS operations. Python versions 2.7 (and higher) and 3.5 (and higher) have both TLS 1.2 and TLS 1.3 support.

What's here:

  • duo_universal - The Python Duo SDK for interacting with the Duo Universal Prompt
  • demo - An example web application with Duo integrated
  • tests - Test cases

Getting Started

To use the SDK in your existing development environment, install it from pypi (https://pypi.org/project/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.

Contribute

To contribute, fork this repo and make a pull request with your changes when they're ready.

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:

python3 -m venv env
source env/bin/activate

Build and install the SDK from source:

pip3 install -r requirements.txt
pip3 install .

Tests

Install the test requirements:

cd tests
pip3 install -r requirements.txt

Then run tests from the test directory:

# Run an individual test file
python3 <test_name>.py

# Run all tests with unittest
python3 -m unittest

Lint

flake8

Support

Please report any bugs, feature requests, or issues to us directly at [email protected].

Thank you for using Duo!

https://duo.com/

duo_universal_python's People

Contributors

aaronatduo avatar gcoxmoz avatar jeffreyparker avatar mbish avatar nstojcevich avatar rpcope1 avatar xdesai avatar yizshi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

duo_universal_python's Issues

Parameter limits disagree with Duo documentation

Description

The code comments for the state parameter indicate the minimum length of state is 22 characters, but the Duo docs (https://duo.com/docs/oauthapi#authorization-request) indicate it's 16. Let's reconcile the two.

Expected Behavior

Anywhere the parameter limits (state and nonce primarily) are described, they agree with the Duo documentation.

Actual Behavior

The state parameter limits disagree.

Steps to Reproduce

N/A

Workarounds

N/A

M1 Mac Install

I am currently running a late 2020 MacBook Air with an M1 chip and I was unable to install using conda / pip through any of the suggested channels. Curious if anyone else had any luck installing the package on an M1 Mac and what your process was to get it to work. Please let me know if you need any more information and I'm happy to provide it.

PyPI tarball is broken

The PyPI tarball doesn't include the requirements.txt file which is explicitly used by setup.py

Duo Universal Prompt in iFrame?

Hi! This is really more of a user-experience issue that I'm having, but I was wondering whether there is any way to embed the new universal prompt into my existing website without having the user redirected to the Duo website and then back to mine? From a user perspective, it is quite jarring to go from my website with one (let's say dark) color palette and then to be tossed into a really bright one on the splash screen. If I could embed an iframe of basically just the prompt into my own website, like the old prompt allowed me to do, I think that it would be a much more seamless experience for my users. Happy to talk about it, thanks!

CORS error while trying to redirect to duo url.

Hello,
I have followed the demos and I am getting CORS error on browser when I am trying to redirect to the prompt_uri.
Any idea why?

.
.
.
    prompt_uri = duo_client.create_auth_url(username, state)

    # Redirect to prompt URI which will redirect to the client's redirect URI
    # after 2FA
    return redirect(prompt_uri)
.
.
.

image

CERTIFICATE_VERIFY_FAILED error due to missing parameter in duo.conf

Following readme still leads to

duo_universal.client.DuoException: HTTPSConnectionPool(host='api-duo1.duo.test', port=443): Max retries exceeded with url: /oauth/v1/health_check (Caused by SSLError(SSLCertVerificationError(1, '[SSL: CERTIFICATE_VERIFY_FAILED] certificate verify failed: self-signed certificate (_ssl.c:997)')))

Solve it by adding

duo_certs = DISABLE

to your duo.conf file

Description

Expected Behavior

Actual Behavior

Steps to Reproduce

Workarounds

Constraint on pyjwt<2 is breaking things

Hi,
I am trying to migrate to this package (as part of migrating to the universal prompt - https://duo.com/docs/universal-prompt-update-guide)
However, the constraint on the pyjwt conflicts with another package that we use:https://github.com/python-social-auth/social-core/blob/master/requirements-base.txt#L4
Note that the reason tests are breaking is because pyjwt 2 dropped support for python 2.7 and python 3.5 both are EOL for a while now...
Maybe this library can drop support for those too ?
Alternatively, the setup.py can be modified to have a different pyjwt for different python version, i.e. python 3.5 & 2.7 have the pyjwt<2 constraint and for newer versions the constraint can be pyjwt>=2

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.