From 40cd59dd284250067cb50b3fb6856074ca22b4fe Mon Sep 17 00:00:00 2001 From: khushal Date: Fri, 13 Dec 2024 20:41:15 +0530 Subject: [PATCH] (20241213) Safety push. --- .../finstitutions/payments/__init__.py | 0 .../finstitutions/{ => payments}/auth.py | 0 models/api/finstitutions/__init__.py | 0 models/api/finstitutions/payments/__init__.py | 0 models/api/finstitutions/payments/auth.py | 159 ++++++++++++++++++ 5 files changed, 159 insertions(+) create mode 100644 api/blueprints/finstitutions/payments/__init__.py rename api/blueprints/finstitutions/{ => payments}/auth.py (100%) create mode 100644 models/api/finstitutions/__init__.py create mode 100644 models/api/finstitutions/payments/__init__.py create mode 100644 models/api/finstitutions/payments/auth.py diff --git a/api/blueprints/finstitutions/payments/__init__.py b/api/blueprints/finstitutions/payments/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/api/blueprints/finstitutions/auth.py b/api/blueprints/finstitutions/payments/auth.py similarity index 100% rename from api/blueprints/finstitutions/auth.py rename to api/blueprints/finstitutions/payments/auth.py diff --git a/models/api/finstitutions/__init__.py b/models/api/finstitutions/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/models/api/finstitutions/payments/__init__.py b/models/api/finstitutions/payments/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/models/api/finstitutions/payments/auth.py b/models/api/finstitutions/payments/auth.py new file mode 100644 index 0000000..0f1966f --- /dev/null +++ b/models/api/finstitutions/payments/auth.py @@ -0,0 +1,159 @@ +""" + + AUTHOR: + + Khushal P Soonderji + + DATE: + + Friday, 13th Dec., 2024. + + OBJECTIVE: + + To provide a structure to receive auth details of various software. + + REFERENCES: + + N/A + + DOWNLOADS: + + N/A + +""" + + +# ***************************************************************************************************************** +# ***** **** +# *** IMPORT *** +# ***** **** +# ***************************************************************************************************************** + + +# To make sibling directories accessible for imports: +import sys +sys.path.append(".") +sys.path.append("..") + +# For making data behaviour_models: +from pydantic import BaseModel, Field, field_validator, PastDatetime +from typing import Optional, Literal, Union + +# My utils: +from utils_v2.string import regex +from utils_v2.date_time import date_time + +# To work with date and time: +import datetime + + +# ***************************************************************************************************************** +# ***** **** +# *** MACROS / ONE-TIME INIT *** +# ***** **** +# ***************************************************************************************************************** + + +# RegEx Patterns: +REGEX_SESSION_TOKEN = r"^[a-f0-9]{8}-[a-f0-9]{4}-[1-5][a-f0-9]{3}-[89ab][a-f0-9]{3}-[a-f0-9]{12}$" + + +# ***************************************************************************************************************** +# ***** **** +# *** VARIABLES *** +# ***** **** +# ***************************************************************************************************************** + + +# --- Nothing Yet + + +# ***************************************************************************************************************** +# ***** **** +# *** FUNCTIONS *** +# ***** **** +# ***************************************************************************************************************** + + +class TheCAOfficeAIAuth(BaseModel): + + authorizeSoftware: bool = Field( + description = "god knows; don't ask", + frozen = True + ) + + authorizeMailMessaging: bool = Field( + description = "god knows; don't ask", + frozen = True + ) + + authorizeCompliancePortal: bool = Field( + description = "god knows; don't ask", + frozen = True + ) + + authorizeFinancialInstitution: bool = Field( + description = "god knows; don't ask", + frozen = True + ) + + # ┏┓ ┏• + # ┃ ┏┓┏┓╋┓┏┓ + # ┗┛┗┛┛┗┛┗┗┫ + # ┛ + + class Config: + extra = "forbid" + + +# --------------------------------------------------------------------------------------------------------------------- + + +class SoftwareAuthRequestHeaders(BaseModel): + + sessionToken: str = Field( + description = "the session token of the user who is requesting the service", + pattern = REGEX_SESSION_TOKEN, + frozen = True, + alias = "X-Session-Token" + ) + + # ┏┓ ┏• + # ┃ ┏┓┏┓╋┓┏┓ + # ┗┛┗┛┛┗┛┗┗┫ + # ┛ + + class Config: + extra = "allow" + + def model_dump(self, *args, **kwargs): + return super().model_dump(*args, by_alias = True, **kwargs) + + +# --------------------------------------------------------------------------------------------------------------------- + + +class SoftwareAuthRequestData(BaseModel): + + softwareClient: Literal["theCaOfficeAi"] = Field(alias = "client") + auth: Union[TheCAOfficeAIAuth] + + # ┏┓ ┏• + # ┃ ┏┓┏┓╋┓┏┓ + # ┗┛┗┛┛┗┛┗┗┫ + # ┛ + + class Config: + extra = "forbid" + + +# ***************************************************************************************************************** +# ***** **** +# *** MAIN PROGRAM *** +# ***** **** +# ***************************************************************************************************************** + + +if __name__ == "__main__": + + pass