|
1 |
| -# ******************************************** |
2 |
| -# |docname| - Configuring Runestone BookServer |
3 |
| -# ******************************************** |
4 |
| -# Many thing about Runestone BookServer are configurable. This is the place to change |
5 |
| -# the configuration for most things. **Private** things should be configured in the |
6 |
| -# environment so they are not accidentally committed to Github. |
7 |
| -# Defaults provided here may be overridden by environment variables `Per <https://fastapi.tiangolo.com/advanced/settings/>`_. |
| 1 | +""" |
| 2 | +Configuring Runestone Servers |
| 3 | +============================= |
| 4 | +
|
| 5 | +Many things about Runestone servers are configurable. This is the place to change |
| 6 | +the configuration for most things. **Private** things should be configured in the |
| 7 | +environment so they are not accidentally committed to Github. |
| 8 | +Defaults provided here may be overridden by environment variables `Per <https://fastapi.tiangolo.com/advanced/settings/>`_. |
| 9 | +""" |
8 | 10 | #
|
9 | 11 | #
|
10 | 12 | # Imports
|
@@ -44,13 +46,15 @@ class DatabaseType(Enum):
|
44 | 46 |
|
45 | 47 |
|
46 | 48 | class Settings(BaseSettings):
|
47 |
| - # Pydantic provides a wonderful utility to handle settings. The beauty of it |
48 |
| - # is that you can specify variables with or without default values, and Pydantic |
49 |
| - # will check your environment variables in a case-insensitive way. So that |
50 |
| - # if you have ``PROD_DBURL``` set in the environment it will be set as the value |
51 |
| - # for ``prod_dburl``` in settings. |
52 |
| - # This is a really nice way to keep from |
53 |
| - # committing any data you want to keep private. |
| 49 | + """ |
| 50 | + Pydantic provides a wonderful utility to handle settings. The beauty of it |
| 51 | + is that you can specify variables with or without default values, and Pydantic |
| 52 | + will check your environment variables in a case-insensitive way. So that |
| 53 | + if you have ``PROD_DBURL``` set in the environment it will be set as the value |
| 54 | + for ``prod_dburl``` in settings. |
| 55 | + This is a really nice way to keep from |
| 56 | + committing any data you want to keep private. |
| 57 | + """ |
54 | 58 |
|
55 | 59 | class Config:
|
56 | 60 | env_file = ".env"
|
@@ -148,6 +152,14 @@ def database_type(self) -> DatabaseType:
|
148 | 152 | # This is the private key web2py uses for hashing passwords.
|
149 | 153 | @property
|
150 | 154 | def web2py_private_key(self) -> str:
|
| 155 | + """Get the web2py private key. |
| 156 | + Prefer to get it from the environment. This allows us to avoid introducing a secret |
| 157 | + into the codebase, and it also avoids the need to mount a volume to the container to |
| 158 | + store the key in a file. |
| 159 | +
|
| 160 | + :return: The web2py private key. |
| 161 | + :rtype: str |
| 162 | + """ |
151 | 163 | # Put the cache here; above the def, it produces ``TypeError: unhashable type: 'Settings'``.
|
152 | 164 | @lru_cache
|
153 | 165 | def read_key():
|
|
0 commit comments