Skip to content
Snippets Groups Projects
Commit 500849f6 authored by Ferenc Schulcz's avatar Ferenc Schulcz
Browse files

Make public endpoints accessible by logged-in users

parent 6178ef66
Branches
No related tags found
No related merge requests found
......@@ -39,8 +39,8 @@ def plugin_add_endpoint(endpoint_id: str, handler, permission_name: str, method=
"""Add a dynamic endpoint."""
""" id: used in the url (like /something)"""
""" handler: pointer to handler function"""
""" servicename: service identifier for authorization. If None, it is a public (and public-only) endpoint."""
""" method: HTTP method this endpoint can handle. If you plan to handle multiple endpoints, call this function multiple times. (Make sure to only add a menu once.)"""
""" servicename: service identifier for authorization. If None, it is a public endpoint"""
""" method: HTTP method this endpoint can handle. If you plan to handle multiple methods with one endpoint, call this function multiple times. (Make sure to only add a menu once.)"""
""" menutext: Text to appear in the menu. If None, no menu item is added."""
if permission_name == None:
......@@ -322,9 +322,14 @@ def service(**kwargs):
return redirect(url_for('login', next=servicename))
return handler(session=session, request=request, rqtools=RequestTools())
else:
# Search for authorized endpoint or public endpoint
(permission_name, handler) = get_authorized_endpoint(servicename, request.method)
if handler == None:
handler = get_public_endpoint(servicename, request.method)
if handler == None:
return get_404(None)
else:
return handler(session=session, request=request, rqtools=RequestTools())
if not services.authorize_user(session['username'], permission_name):
return get_403(None)
return handler(session=session, request=request, rqtools=RequestTools())
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment