puiterwijk / flask-oidc

OpenID Connect support for Flask
BSD 2-Clause "Simplified" License
154 stars 217 forks source link

Mark this project as deprecated. #85

Open sonthonaxrk opened 5 years ago

sonthonaxrk commented 5 years ago

This project has a large number of design issues, doesn't conform to the OIDC spec, and does some unexpected things. I'm currently refactoring this out of a project and it's surprised me on a few occasions. I appreciate it solves some issues for some people, but in the long run, doing unexpected things creates issues with interoperability and extensions.

There are also some minor security issues (forgive me if I'm wrong about any of the particulars).

Given the better tools to do this like oauthlib, and pyjwt to do this job, (and probably something higher level too) perhaps the maintainers should point new projects to these tools instead.


General issues with the code:

MartinThoma commented 5 years ago

I recently started using it. The only reason for it was that there is a couple of examples how to make it work with Okta, e.g. like this:

from flask import Flask, url_for, redirect
from flask_oidc import OpenIDConnect

app = Flask(__name__)
app.config['OIDC_CLIENT_SECRETS'] = 'client_secrets.json'
# Contents:
# Create client_id and client_secret at https://console.developers.google.com/apis/credentials
# {
#     "web": {
#         "client_id": "123456789012-abc123hi09123.apps.googleusercontent.com",
#         "client_secret": "ab123456789ABCDEFGHIJKLM",
#         "redirect_uris": ["http://localhost:5000"],
#         "auth_uri": "https://accounts.google.com/o/oauth2/auth",
#         "token_uri": "https://accounts.google.com/o/oauth2/token",
#         "userinfo_uri": "https://www.googleapis.com/oauth2/v3/userinfo"
#     }
# }
app.config['SECRET_KEY'] = 'uq4aKjUvWXTPTIyfCz7mTtcG'
app.config['OIDC_ID_TOKEN_COOKIE_SECURE'] = False
app.config['OIDC_SCOPES'] = ["openid", "profile", "email"]
app.config['OIDC_CALLBACK_ROUTE'] = '/authorization-code/callback'
oidc = OpenIDConnect(app)

@app.route('/')
@oidc.require_login
def index():
    return redirect(url_for('personalized'))

@app.route('/personalized')
@oidc.require_login
def personalized():
    info = oidc.user_getinfo(['email', 'openid_id'])
    return 'Hello, {} ({})'.format(info.get('email'), info.get('openid_id'))

@app.route('/hello')
@oidc.require_login
def constant():
    return 'Hello'

if __name__ == '__main__':
    app.run(port=5000)

If there was an alternative that also provided a require_login decorator and works with Okta, I'd be happy to switch.

MartinThoma commented 5 years ago

This is related to #81

MartinThoma commented 5 years ago

And #60

jorenvh1 commented 5 years ago

I am also running into some troubles... I'm trying to use this library with the Okta implicit flow (intospect call without client secret). I'll probably make a pull-request to add this but it's weird that it's not following that spec...

sonthonaxrk commented 4 years ago

@MartinThoma my advice would be to roll your own code. You really just need a decorator to do a check for the authorization cookie being valid (a few lines with pyjwt), and an OIDC callback view built on top of oauthlib and pyjwt/jose.

OIDC isn't as complex as it seems.

svintit commented 4 years ago

If you want this resolved i'm maintaining a fork of this with some added extensibility. Feel free to open a PR/issue here: