Dan Albert 4e348dd99a Add a server setting for disabling the API key.
Useful for development if you want to disable API key authentication for
debugging the server without having to pull the generated key out of the
log every time.
2022-02-28 00:31:56 -08:00

35 lines
1.0 KiB
Python

from __future__ import annotations
from functools import lru_cache
from pydantic import BaseSettings
class ServerSettings(BaseSettings):
"""Settings controlling server behavior.
The values listed here will be automatically modified based on the environment. e.g.
running with SERVER_BIND_ADDRESS=0.0.0.0 will cause the server to bind to all
interfaces.
https://fastapi.tiangolo.com/advanced/settings
"""
# WARNING: Be extremely cautious exposing the server to other machines. As there is
# no client/server workflow yet, security has not been a focus.
server_bind_address: str = "::1"
# If you for some reason change the port, you'll need to also update map.js.
server_port: int = 5000
# Disable to allow requests to be made to the backend without an API key.
require_api_key: bool = True
# Enable to allow cross-origin requests from http://localhost:3000.
cors_allow_debug_server: bool = False
@classmethod
@lru_cache
def get(cls) -> ServerSettings:
return cls()