aboutsummaryrefslogtreecommitdiff
path: root/gn3/auth/authentication/oauth2/views.py
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-02-02 11:35:51 +0300
committerFrederick Muriuki Muriithi2023-02-02 12:03:51 +0300
commitdfe5eb18e3ec8dc570d118bfe95c5d4dcb2c7575 (patch)
treeb45da1e9eba405042ef47174215b827739f5a393 /gn3/auth/authentication/oauth2/views.py
parent6fc120aca6062f96725adaece85a7b76000affda (diff)
downloadgenenetwork3-dfe5eb18e3ec8dc570d118bfe95c5d4dcb2c7575.tar.gz
auth: Reorganise modules/packages for easier dev and maintenance
Split the views/routes into separate modules each dealing with a narrower scope of the application to aid in maintenance, and help with making the development easier.
Diffstat (limited to 'gn3/auth/authentication/oauth2/views.py')
-rw-r--r--gn3/auth/authentication/oauth2/views.py16
1 files changed, 8 insertions, 8 deletions
diff --git a/gn3/auth/authentication/oauth2/views.py b/gn3/auth/authentication/oauth2/views.py
index 3af83e2..e440c6e 100644
--- a/gn3/auth/authentication/oauth2/views.py
+++ b/gn3/auth/authentication/oauth2/views.py
@@ -1,41 +1,41 @@
"""Endpoints for the oauth2 server"""
import uuid
-from flask import current_app as app
+from flask import Blueprint, current_app as app
-from gn3.auth.blueprint import oauth2
from .endpoints.revocation import RevocationEndpoint
from .endpoints.introspection import IntrospectionEndpoint
+auth = Blueprint("auth", __name__)
-@oauth2.route("/register-client", methods=["GET", "POST"])
+@auth.route("/register-client", methods=["GET", "POST"])
def register_client():
"""Register an OAuth2 client."""
return "WOULD REGISTER ..."
-@oauth2.route("/delete-client/<uuid:client_id>", methods=["GET", "POST"])
+@auth.route("/delete-client/<uuid:client_id>", methods=["GET", "POST"])
def delete_client(client_id: uuid.UUID):
"""Delete an OAuth2 client."""
return f"WOULD DELETE OAUTH2 CLIENT {client_id}."
-@oauth2.route("/authorise", methods=["GET", "POST"])
+@auth.route("/authorise", methods=["GET", "POST"])
def authorise():
"""Authorise a user"""
return "WOULD AUTHORISE THE USER."
-@oauth2.route("/token", methods=["POST"])
+@auth.route("/token", methods=["POST"])
def token():
"""Retrieve the authorisation token."""
server = app.config["OAUTH2_SERVER"]
return server.create_token_response()
-@oauth2.route("/revoke", methods=["POST"])
+@auth.route("/revoke", methods=["POST"])
def revoke_token():
"""Revoke the token."""
return app.config["OAUTH2_SERVER"].create_endpoint_response(
RevocationEndpoint.ENDPOINT_NAME)
-@oauth2.route("/introspect", methods=["POST"])
+@auth.route("/introspect", methods=["POST"])
def introspect_token():
"""Provide introspection information for the token."""
return app.config["OAUTH2_SERVER"].create_endpoint_response(