feat: Add OAuth2 server and client implementation with PKCE support
- Implemented OAuth2 server with client registration, authorization, and token endpoints. - Created HTML templates for client authorization, client creation, and client editing. - Developed an OAuth2 client application using Hono.js and Bun, supporting authorization code grant flow. - Integrated PKCE (Proof Key for Code Exchange) for enhanced security during authorization. - Added session management using cookies for user authentication. - Included detailed README documentation for setup and usage instructions.
This commit is contained in:
commit
7cd05b5c6a
29 changed files with 1962 additions and 0 deletions
36
example-oauth2-server/website/app.py
Normal file
36
example-oauth2-server/website/app.py
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
import os
|
||||
from flask import Flask
|
||||
from .models import db
|
||||
from .oauth2 import config_oauth
|
||||
from .routes import bp
|
||||
|
||||
|
||||
def create_app(config=None):
|
||||
app = Flask(__name__)
|
||||
|
||||
# load default configuration
|
||||
app.config.from_object('website.settings')
|
||||
|
||||
# load environment configuration
|
||||
if 'WEBSITE_CONF' in os.environ:
|
||||
app.config.from_envvar('WEBSITE_CONF')
|
||||
|
||||
# load app specified configuration
|
||||
if config is not None:
|
||||
if isinstance(config, dict):
|
||||
app.config.update(config)
|
||||
elif config.endswith('.py'):
|
||||
app.config.from_pyfile(config)
|
||||
|
||||
setup_app(app)
|
||||
return app
|
||||
|
||||
|
||||
def setup_app(app):
|
||||
|
||||
db.init_app(app)
|
||||
# Create tables if they do not exist already
|
||||
with app.app_context():
|
||||
db.create_all()
|
||||
config_oauth(app)
|
||||
app.register_blueprint(bp, url_prefix='')
|
||||
Loading…
Add table
Add a link
Reference in a new issue