Skip to content

Commit 11461af

Browse files
committed
Upgrade requirements
Avoid pre-mature validation for username and password fields Bump version
1 parent 2f9b168 commit 11461af

File tree

4 files changed

+20
-27
lines changed

4 files changed

+20
-27
lines changed

release_notes.rst

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
Release Notes
22
=============
33

4+
v0.2.1 (11/25/2025)
5+
-------------------
6+
- **fix**: Avoid pre-mature validation for username and password fields
7+
- **chore**: Upgrade requirements
8+
- **Full Changelog**: https://github.com/thevickypedia/FastAPIAuthenticator/compare/v0.2.0...v0.2.1
9+
410
v0.2.0 (07/03/2025)
511
-------------------
612
- **feature**: Includes an option to pass custom logger

requirements.txt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
fastapi==0.115.*
2-
jinja2==3.1.*
3-
pydantic==2.11.*
4-
python-dotenv==1.1.*
1+
fastapi==0.122.*
2+
Jinja2==3.1.*
3+
pydantic==2.12.*
4+
python-dotenv==1.2.*

uiauth/models.py

Lines changed: 9 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
from fastapi.routing import APIRoute, APIWebSocketRoute
66
from fastapi.templating import Jinja2Templates
7-
from pydantic import BaseModel, Field, ValidationInfo, field_validator
7+
from pydantic import BaseModel, Field
88

99
from uiauth.enums import APIMethods
1010

@@ -32,30 +32,17 @@ def get_env(keys: List[str], default: Optional[str] = None) -> Optional[str]:
3232

3333

3434
class EnvConfig(BaseModel):
35-
"""Configuration for environment variables."""
35+
"""Configuration for environment variables.
3636
37-
username: str
38-
password: str
37+
>>> EnvConfig
3938
40-
# noinspection PyMethodParameters
41-
@field_validator("username", "password", mode="before")
42-
def load_user(cls, key: str, field: ValidationInfo) -> str | None:
43-
"""Load environment variables into the configuration.
44-
45-
Args:
46-
key: Environment variable key to check.
47-
field: Field information for validation.
48-
49-
See Also:
50-
- This method checks if the environment variable is set and returns its value.
51-
- If the key is not set, it attempts to get the value from the environment using a helper function.
39+
See Also:
40+
- Tries to resolve username and password through kwargs.
41+
- Uses environment variables as fallback.
42+
"""
5243

53-
Returns:
54-
str | None:
55-
Value of the environment variable or None if not set.
56-
"""
57-
if not key:
58-
return get_env([field.field_name, field.field_name[:4]])
44+
username: str = Field(default_factory=lambda: get_env(("username", "user")))
45+
password: str = Field(default_factory=lambda: get_env(("password", "pass")))
5946

6047

6148
env = EnvConfig

uiauth/version.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "0.2.0"
1+
version = "0.2.1"

0 commit comments

Comments
 (0)