Skip to main content

Useful tools to work with OIDC in Python and Flask

Project description

SM Flask OIDC

This can be helpfull if you want to implement IdentityServer4 OIDC in Flask Python application

How to use:

Install: python -m pip install sm-flask-oidc Upgrade: python -m pip install sm-flask-oidc --upgrade

Import: from sm_flask_oidc import sm_flask_oidc_helper

Define Params: CLIENT_ID = '' CLIENT_SECRET = '' APP_URI = '' AUTH_API_ROUTE = '' AUTH_STATE = ''

Activate Flask Session: app.secret_key = "my-super-secret"

Create instance: sm_oidc = sm_flask_oidc_helper.SmFlaskOidcHelper(CLIENT_ID, CLIENT_SECRET, APP_URI, AUTH_API_ROUTE, AUTH_STATE)

Define Required Routes:

@app.route("/login")
def login():
    return sm_oidc.login()

@app.route("/login-callback")
def login_callback():
    return sm_oidc.login_callback()

@app.route("/logout")
def logout():
    return sm_oidc.logout()

@app.route("/logout-callback")
def logout_callback():
    return sm_oidc.logout_callback()

Notes:

After login the following keys will be added to flask.session: id_token, name, email, is_authorized

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

sm-flask-oidc-1.0.9.tar.gz (3.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

sm_flask_oidc-1.0.9-py3-none-any.whl (4.0 kB view details)

Uploaded Python 3

File details

Details for the file sm-flask-oidc-1.0.9.tar.gz.

File metadata

  • Download URL: sm-flask-oidc-1.0.9.tar.gz
  • Upload date:
  • Size: 3.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.8.0 tqdm/4.37.0 CPython/3.7.0

File hashes

Hashes for sm-flask-oidc-1.0.9.tar.gz
Algorithm Hash digest
SHA256 977642f894c0aec8c53e3916e6cfef16c1bb502e441381fbd451d67e596ac018
MD5 ce47707daf6b27487f4329f4aacbcab7
BLAKE2b-256 274bd18b977e94da0f0e41e292d80c7e5e0aef9fa2fc86bf0a8610e91048e662

See more details on using hashes here.

File details

Details for the file sm_flask_oidc-1.0.9-py3-none-any.whl.

File metadata

  • Download URL: sm_flask_oidc-1.0.9-py3-none-any.whl
  • Upload date:
  • Size: 4.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/2.0.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/41.6.0 requests-toolbelt/0.8.0 tqdm/4.37.0 CPython/3.7.0

File hashes

Hashes for sm_flask_oidc-1.0.9-py3-none-any.whl
Algorithm Hash digest
SHA256 5bc34e689a81ef3a38d73fd3e432502088e728672b2eeccdf72a91e8c0a2be61
MD5 1f1f5720fb86e6d809b38d6f96b43159
BLAKE2b-256 4c244142cbe23200fe60e58c937d4f93fdc21bd03f7dfea2dd8bdfeb50f8131a

See more details on using hashes here.

Supported by

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