Skip to content
Snippets Groups Projects
Verified Commit b4fccc88 authored by Karel van Klink's avatar Karel van Klink :smiley_cat:
Browse files

update docstrings

parent 6d943253
No related branches found
No related tags found
1 merge request!161Feature/add mailer service
Pipeline #85726 passed
......@@ -9,6 +9,7 @@ repos:
- --fix
- --preview
- --ignore=PLR0917,PLR0914
- --extend-exclude=test/*
# Run the formatter.
- id: ruff-format
args:
......
......@@ -58,6 +58,9 @@ Glossary of terms
Simple Network Management Protocol: a protocol that's used for gathering data, widely used for network management
and monitoring.
TWAMP
Two-way Active Measurement Protocol.
UUID
Universally Unique Identifier
......
......@@ -14,4 +14,6 @@ Dark_fiber
PHASE 1
[Mm]odify
AAI
[M|m]iddleware
\ No newline at end of file
[M|m]iddleware
TWAMP
Pydantic
......@@ -82,13 +82,8 @@ class OIDCUserModel(dict):
if the attribute is one of the registered claims or raises an AttributeError
if the key is not found.
Args:
----
key: The attribute name to retrieve.
Returns:
-------
The value of the attribute if it exists, otherwise raises AttributeError.
:param str key: The attribute name to retrieve.
:return: The value of the attribute if it exists, otherwise raises AttributeError.
"""
try:
return object.__getattribute__(self, key)
......@@ -167,6 +162,7 @@ class OPAResult(BaseModel):
----------
- result (bool): Indicates whether the access request is allowed or denied.
- decision_id (str): A unique identifier for the decision made by OPA.
"""
result: bool = False
......@@ -208,15 +204,10 @@ class OIDCUser(HTTPBearer):
This is used as a security module in Fastapi projects
Args:
----
request: Starlette request method.
token: Optional value to directly pass a token.
Returns:
-------
OIDCUserModel object.
:param Request request: Starlette request method.
:param str token: Optional value to directly pass a token.
:return: OIDCUserModel object.
"""
if not oauth2lib_settings.OAUTH2_ACTIVE:
return None
......@@ -380,16 +371,12 @@ def opa_decision(
to authorize requests based on OPA policies. It utilizes OIDC for user information and makes a
call to the OPA service to determine authorization.
Args:
----
opa_url: URL of the Open Policy Agent service.
oidc_security: An instance of OIDCUser for user authentication.
auto_error: If True, automatically raises an HTTPException on authorization failure.
opa_kwargs: Additional keyword arguments to be passed to the OPA input.
:param str opa_url: URL of the Open Policy Agent service.
:param OIDCUser oidc_security: An instance of OIDCUser for user authentication.
:param bool auto_error: If True, automatically raises an HTTPException on authorization failure.
:param Mapping[str, str] | None opa_kwargs: Additional keyword arguments to be passed to the OPA input.
Returns:
-------
An asynchronous decision function that can be used as a dependency in FastAPI endpoints.
:return: An asynchronous decision function that can be used as a dependency in FastAPI endpoints.
"""
async def _opa_decision(
......@@ -407,6 +394,7 @@ def opa_decision(
request: Request object that will be used to retrieve request metadata.
user_info: The OIDCUserModel object that will be checked
async_request: The :term:`httpx` client.
"""
if not (oauth2lib_settings.OAUTH2_ACTIVE and oauth2lib_settings.OAUTH2_AUTHORIZATION_ACTIVE):
return None
......
......@@ -34,8 +34,6 @@ def get_oidc_user() -> OIDCUser:
This function returns the instance of OIDCUser initialized in the module.
It is typically used for accessing the OIDCUser across different parts of the application.
Returns
-------
OIDCUser: The instance of OIDCUser configured with OAuth2 settings.
:return OIDCUser: The instance of OIDCUser configured with OAuth2 settings.
"""
return oidc_user
......@@ -140,7 +140,7 @@ class WorkflowInstanceForTests(LazyWorkflowInstance):
This can be as simple as merely importing a workflow function. However, if it concerns a workflow generating
function, that function will be called with or without arguments as specified.
Returns: A workflow function.
:return Workflow: A workflow function.
"""
self.workflow.name = self.name
return self.workflow
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment