/edison

Authentication middleware for JWT auth in Flask and Django apps

Primary LanguagePythonMIT LicenseMIT

edison

Authentication middleware for JWT auth in Flask and Django apps

edison architecture

Usage


Django Integration

settings.py

MIDDLEWARE_CLASSES = [
  'django.middleware.security.SecurityMiddleware',
  ...
  'edison.middlewares.jwt_authentication_middleware.JWTAuthenticationMiddleware'
]

EDISON = {
    'JWT_AUTHENTICATION_HEADER': 'TOKEN',
    'JWT_VALIDATOR_URL': 'http://localhost:3000/jwt_verify',
    'JWT_FAILED_REDIRECT_URL': 'http://google.com'
}

Flask Integration

use as decorator function

    # app.py
    from flask import render_template
    from edison.middleware.flask import edison_jwt_authentication_required

    @app.route('/only-auth-users')
    @edison_jwt_authentication_required(jwt_authentication_header='TOKEN')
    def only_auth_users():
      return render_template('only_auth_users.html')

Join me make JWT even more awesome!


👍👍👍👍👍👍👍👍👍