diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 70bfc27e17dce4bdd2df10ee86b2490ec7789d98..6c9492b7ac47f817ba2ae745a1687c1785d058ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -9,6 +9,7 @@ repos: - --fix - --preview - --ignore=PLR0917,PLR0914 + - --extend-exclude=test/* # Run the formatter. - id: ruff-format args: diff --git a/docs/source/glossary.rst b/docs/source/glossary.rst index 959d89761d27f3652cbae2d840a5e2ef2f7a3703..0bbcce276f79bee067aef114ea5b0f0c3101ab39 100644 --- a/docs/source/glossary.rst +++ b/docs/source/glossary.rst @@ -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 diff --git a/docs/vale/styles/config/vocabularies/geant-jargon/accept.txt b/docs/vale/styles/config/vocabularies/geant-jargon/accept.txt index 081f7913cba3d95518c76bfb75278bdf9300dbf8..9172c42e39a10632a75a6e73c17dd9b0e9b5eb41 100644 --- a/docs/vale/styles/config/vocabularies/geant-jargon/accept.txt +++ b/docs/vale/styles/config/vocabularies/geant-jargon/accept.txt @@ -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 diff --git a/gso/auth/oidc_policy_helper.py b/gso/auth/oidc_policy_helper.py index 04e2fc8e5ec419fb5f80a6a5646bb3429512cad9..241641dcfe3a93ffd41bb2962255c6557b95d235 100644 --- a/gso/auth/oidc_policy_helper.py +++ b/gso/auth/oidc_policy_helper.py @@ -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 diff --git a/gso/auth/security.py b/gso/auth/security.py index 16065e467e02176d92df20563c4c3e0f56845667..e1d5376479e9e95f50847af06fa7120272135a4a 100644 --- a/gso/auth/security.py +++ b/gso/auth/security.py @@ -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 diff --git a/test/workflows/__init__.py b/test/workflows/__init__.py index 669fd75cf6b91057d0c327b0dbc111abb63e6f8f..5470858c105666ac8396b42649c65a02eeef8d0c 100644 --- a/test/workflows/__init__.py +++ b/test/workflows/__init__.py @@ -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