Skip to content

Commit

Permalink
Merge pull request #20 from tmeiczin/tjm/auth
Browse files Browse the repository at this point in the history
exempt openapi from auth
  • Loading branch information
tmeiczin authored May 16, 2024
2 parents aab1897 + cbcb529 commit 4a68de9
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
5 changes: 5 additions & 0 deletions src/reliqua/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -677,6 +677,11 @@ def process_resource(self, req, resp, resource, _params):
user = None
authorized = False

# if resource has explicit no_auth, always skip
# authentication.
if getattr(resource, "no_auth", False):
return

# check if request requires authentication
if not self.control.authentication_required(req.uri_template, req.method, resource):
return
Expand Down
6 changes: 5 additions & 1 deletion src/reliqua/docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Copyright 2016-2024.
"""

from reliqua.resources.base import Resource


def default_responses():
"""Return default response schema."""
Expand All @@ -17,7 +19,7 @@ def default_responses():
}


class Docs:
class Docs(Resource):
"""
Documents endpoint class.
Expand Down Expand Up @@ -59,6 +61,8 @@ class Docs:
The return type of the method.
"""

no_auth = True

def __init__(self, schema):
"""
Create Docs instance.
Expand Down
13 changes: 10 additions & 3 deletions src/reliqua/swagger.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
Copyright 2016-2024.
"""

from reliqua.resources.base import Resource

from .status_codes import HTTP


Expand Down Expand Up @@ -57,15 +59,20 @@ def index(spec, server, sort="alpha", highlight="true"):
"""


class Swagger:
class Swagger(Resource):
"""Class to server the static swagger files."""

def __init__(self, url, openapi_url, sort="alpha", highlight=True):
no_auth = True

def __init__(self, url, openapi_url, sort="alpha", highlight=True, authenticate=False):
"""
Create a Swagger instance.
:param str url: URL to Swagger instance
:param str swagger_file: URL to Swagger file
:param str openapi_url: URL to OpenAPI spec
:param srt sort: Tag/Endpoint sort order
:param bool highlight: Syntax highlighting
:param bool authenticate: Docs need authentication
:return: None
"""
self.url = url
Expand Down

0 comments on commit 4a68de9

Please sign in to comment.