-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
api.config: add module to define various settings
Instead of defining multiple settings class in different API modules like `pubsub`, `auth`, `email_sender`, add `api.config` module to store all different settings classes. Signed-off-by: Jeny Sadadia <[email protected]> Signed-off-by: Guillaume Tucker <[email protected]>
- Loading branch information
1 parent
8afe94f
commit 936938e
Showing
5 changed files
with
41 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
# SPDX-License-Identifier: LGPL-2.1-or-later | ||
# | ||
# Copyright (C) 2023 Collabora Limited | ||
# Author: Jeny Sadadia <[email protected]> | ||
|
||
"""Module settings""" | ||
|
||
from pydantic import BaseSettings, EmailStr | ||
|
||
|
||
class AuthSettings(BaseSettings): | ||
"""Authentication settings""" | ||
secret_key: str | ||
algorithm: str = "HS256" | ||
# Set to None so tokens don't expire | ||
access_token_expire_seconds: float = None | ||
|
||
|
||
class PubSubSettings(BaseSettings): | ||
"""Pub/Sub settings loaded from the environment""" | ||
cloud_events_source: str = "https://api.kernelci.org/" | ||
redis_host: str = "redis" | ||
redis_db_number: int = 1 | ||
keep_alive_period: int = 45 | ||
|
||
|
||
class EmailSettings(BaseSettings): | ||
"""Email settings""" | ||
smtp_host: str | ||
smtp_port: int | ||
email_sender: EmailStr | ||
email_password: str |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters