Skip to content

Commit

Permalink
Use secret str (#215)
Browse files Browse the repository at this point in the history
* use SecretStr for password in ConnectionConfig

* Format code
  • Loading branch information
przemoch-dev authored Nov 15, 2024
1 parent a4aff1a commit 969ea5c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 2 additions & 2 deletions fastapi_mail/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@

from aiosmtplib.api import DEFAULT_TIMEOUT
from jinja2 import Environment, FileSystemLoader
from pydantic import DirectoryPath, EmailStr, conint
from pydantic import DirectoryPath, EmailStr, SecretStr, conint
from pydantic_settings import BaseSettings as Settings


class ConnectionConfig(Settings):
MAIL_USERNAME: str
MAIL_PASSWORD: str
MAIL_PASSWORD: SecretStr
MAIL_PORT: int
MAIL_SERVER: str
MAIL_STARTTLS: bool
Expand Down
3 changes: 2 additions & 1 deletion fastapi_mail/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ async def _configure_connection(self) -> None:

if self.settings.USE_CREDENTIALS:
await self.session.login(
self.settings.MAIL_USERNAME, self.settings.MAIL_PASSWORD
self.settings.MAIL_USERNAME,
self.settings.MAIL_PASSWORD.get_secret_value(),
)

except Exception as error:
Expand Down

0 comments on commit 969ea5c

Please sign in to comment.