feat(api): support OAuth2.0 and OIDC authentication, it has been tested with casdoor

feat(api): support OAuth2.0 and OIDC authentication, it has been tested with casdoor
This commit is contained in:
pycook
2023-12-12 20:29:57 +08:00
committed by GitHub
parent a06599ce33
commit 21c9d9accd
10 changed files with 340 additions and 10 deletions

View File

@@ -0,0 +1,26 @@
# -*- coding:utf-8 -*-
from flask import current_app
from . import routing
class OAuth2(object):
def __init__(self, app=None, url_prefix=None):
self._app = app
if app is not None:
self.init_app(app, url_prefix)
@staticmethod
def init_app(app, url_prefix=None):
# Configuration defaults
app.config.setdefault('OAUTH2_GRANT_TYPE', 'authorization_code')
app.config.setdefault('OAUTH2_RESPONSE_TYPE', 'code')
app.config.setdefault('OAUTH2_AFTER_LOGIN', '/')
# Register Blueprint
app.register_blueprint(routing.blueprint, url_prefix=url_prefix)
@property
def app(self):
return self._app or current_app