Skip to main content

Used to implement Blue2Factor

Project description

PyB2f

This python package is used for python webservers that use Blue2Factor

It can be used with both Django and Flask.

To install with pip:

pip install Blue2Factor

You may have to install the packages below:

python3 -m pip install jwt rsa django flask requests

Or on GitHub at https://github.com/bk89686/PyB2f

To call in Flask:

from Blue2Factor import Authentication

companyId = "COMPANY_ID from https://secure.blue2factor.com"
loginUrl = "LOGIN_URL that was entered at https://secure.blue2factor.com"

b2f = Authentication.Auth()

@app.route('/mytest', methods=['GET', 'POST'])
def myTest():
    if not b2f.authenticateFlaskRequest(request, companyId, loginUrl, privateKeyStr):
        return b2f.redirect
    #do what you would normally do, and set cookies
    response = Main.Sample().showTestPage()
    return response
    
@app.after_request
def setCookie(response):
    return b2f.setB2fCookie(response)
    
    
#If a user signs out call:
	return b2f.flaskSignout(companyId) 

Or using Django

from Blue2Factor import Authentication

companyId = "COMPANY_ID from https://secure.blue2factor.com"
loginUrl = "LOGIN_URL that was entered at https://secure.blue2factor.com"

b2f = Authentication.Auth()

def index(request):
	if not b2f.authenticateDjangoRequest(request, companyId, loginUrl, privateKeyStr):
        return b2f.redirect
    #do what you normall do
    template = loader.get_template('sample.html')
    response = HttpResponse(template.render())

@app.after_request
def setCookie(response):
    return b2f.setB2fCookie(response)
    
#If a user signs out call:
	return b2f.djangoSignout(companyId)

for questions, please contact us at (607) 238-3522 or help@blue2factor.com

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

Blue2Factor-0.1.5.tar.gz (4.9 kB view details)

Uploaded Source

Built Distribution

Blue2Factor-0.1.5-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file Blue2Factor-0.1.5.tar.gz.

File metadata

  • Download URL: Blue2Factor-0.1.5.tar.gz
  • Upload date:
  • Size: 4.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for Blue2Factor-0.1.5.tar.gz
Algorithm Hash digest
SHA256 c7e22ddd660fea9d259908db6131b7fc592afecce0389ac990d45dea50f72a85
MD5 4d478059262092d0d6b38930b6391f1b
BLAKE2b-256 2aa8067c2657c91fd11b665deefece5e432f6e47ea375fde7184569e3e8f0c07

See more details on using hashes here.

File details

Details for the file Blue2Factor-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: Blue2Factor-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.12

File hashes

Hashes for Blue2Factor-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7468356ce6b036b031a382bce9b609ceb4cad293cfd3f5e43bac86657f8e2965
MD5 4fbdf573f72002cb7244378058e695db
BLAKE2b-256 fca7f4996d2f4f0c5af51441f855e158c2174a105c47ca08159738e251f9c60b

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page