API Reference
Server settings module for configuration and database management.
This module provides server-wide configuration management, including measurement units, currency settings, signup policies, SSO configuration, and map tile server settings.
Exports
- CRUD operations: get_server_settings, edit_server_settings
- Schemas: ServerSettings, ServerSettingsEdit, ServerSettingsRead, ServerSettingsReadPublic
- Utilities: get_server_settings_or_404 (wrapper), get_tile_maps_templates
- Models: ServerSettings (ORM model)
- Enums: Units, Currency, PasswordType
Currency
Bases: Enum
An enumeration representing supported currencies.
Attributes:
| Name | Type | Description |
|---|---|---|
EURO |
Represents the Euro currency. |
|
DOLLAR |
Represents the US Dollar currency. |
|
POUND |
Represents the British Pound currency. |
Source code in backend/app/server_settings/schema.py
35 36 37 38 39 40 41 42 43 44 45 46 47 | |
PasswordType
Bases: Enum
An enumeration representing password policy types.
Attributes:
| Name | Type | Description |
|---|---|---|
STRICT |
str
|
Strict password policy. |
LENGTH_ONLY |
str
|
Length-only password policy. |
Source code in backend/app/server_settings/schema.py
50 51 52 53 54 55 56 57 58 59 60 | |
ServerSettings
Bases: ServerSettingsBase
Internal complete server settings schema with identifier.
Extends ServerSettingsBase by adding the id field for internal operations. Not typically used for API responses.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
StrictInt
|
Unique identifier (always 1, singleton pattern). |
tileserver_api_key |
StrictStr | None
|
API key encrypted for the tile server. |
Source code in backend/app/server_settings/schema.py
245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 | |
ServerSettingsBase
Bases: BaseModel
Pydantic model for server settings configuration.
This model defines all configurable server settings for the Endurain application, including units, currency, authentication methods, map configuration, and password policies.
Attributes:
| Name | Type | Description |
|---|---|---|
units |
Units
|
Unit system for measurements (METRIC or IMPERIAL). |
public_shareable_links |
StrictBool
|
Enable/disable public shareable links. |
public_shareable_links_user_info |
StrictBool
|
Show user info on public shareable links. |
login_photo_set |
StrictBool
|
Whether login photo is configured. |
currency |
Currency
|
Currency type (EURO, DOLLAR, or POUND). |
num_records_per_page |
StrictInt
|
Number of records per page in lists (1-100, default: 25). |
signup_enabled |
StrictBool
|
Allow new user registration. |
sso_enabled |
StrictBool
|
Enable SSO/IdP authentication. |
local_login_enabled |
StrictBool
|
Allow local username/password authentication. |
sso_auto_redirect |
StrictBool
|
Automatically redirect to SSO when only one IdP is configured. |
tileserver_url |
StrictStr
|
URL template for map tile server with coordinate placeholders. |
tileserver_attribution |
StrictStr
|
Attribution string for map tile server. |
map_background_color |
StrictStr
|
Hex color code for map background (#RRGGBB format). |
password_type |
PasswordType
|
Password policy enforcement level (STRICT or LENGTH_ONLY). |
password_length_regular_users |
StrictInt
|
Minimum password length for regular users (8-128, default: 8). |
password_length_admin_users |
StrictInt
|
Minimum password length for admin users (8-128, default: 12). |
Validators
- validate_tileserver_url: Ensures tile server URL is secure, uses proper protocol, contains required placeholders, and blocks dangerous patterns.
- validate_attribution: Sanitizes attribution string to prevent XSS attacks.
Model Config
- Validates on assignment.
- Forbids extra fields.
- Uses enum values in serialization.
- Supports ORM attribute mapping.
Source code in backend/app/server_settings/schema.py
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
validate_attribution
classmethod
validate_attribution(value)
Sanitize tileserver attribution to prevent XSS.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Raw attribution string. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Sanitized string with only safe HTML. |
Source code in backend/app/server_settings/schema.py
230 231 232 233 234 235 236 237 238 239 240 241 242 | |
validate_tileserver_url
classmethod
validate_tileserver_url(value)
Validate tile server URL for security and correctness.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
str
|
Tile server URL template. |
required |
Returns:
| Type | Description |
|---|---|
str
|
Validated URL. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If URL is invalid or insecure. |
Source code in backend/app/server_settings/schema.py
169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 | |
ServerSettingsEdit
Bases: ServerSettings
Edit schema for server settings updates.
Extends ServerSettings with signup requirement fields.
Attributes:
| Name | Type | Description |
|---|---|---|
signup_require_admin_approval |
StrictBool
|
Require admin approval for new sign-ups (true - yes, false - no). |
signup_require_email_verification |
StrictBool
|
Require email verification for new sign-ups (true - yes, false - no). |
Source code in backend/app/server_settings/schema.py
267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
ServerSettingsModel
Bases: Base
Server-wide configuration settings.
Attributes:
| Name | Type | Description |
|---|---|---|
id |
Mapped[int]
|
Primary key (always 1, singleton pattern). |
units |
Mapped[str]
|
Measurement units (metric, imperial). |
public_shareable_links |
Mapped[bool]
|
Allow public shareable links. |
public_shareable_links_user_info |
Mapped[bool]
|
Show user info on public links. |
login_photo_set |
Mapped[bool]
|
Login photo has been configured. |
currency |
Mapped[str]
|
Currency type (euro, dollar, pound). |
num_records_per_page |
Mapped[int]
|
Default pagination size. |
signup_enabled |
Mapped[bool]
|
Allow user registration. |
signup_require_admin_approval |
Mapped[bool]
|
Require approval for new signups. |
signup_require_email_verification |
Mapped[bool]
|
Require email verification for new signups. |
sso_enabled |
Mapped[bool]
|
Enable SSO/IdP login. |
local_login_enabled |
Mapped[bool]
|
Allow local login. |
sso_auto_redirect |
Mapped[bool]
|
Auto-redirect to SSO. |
tileserver_url |
Mapped[str]
|
Map tile server URL template. |
tileserver_attribution |
Mapped[str]
|
Map tile attribution. |
tileserver_api_key |
Mapped[str | None]
|
API key for tile server (encrypted). |
tileserver_regenerate_thumbnails_on_change |
Mapped[bool]
|
Regenerate thumbnails when tile server settings change. |
map_background_color |
Mapped[str]
|
Map background hex color. |
password_type |
Mapped[str]
|
Password policy type. |
password_length_regular_users |
Mapped[int]
|
Min password length for regular users. |
password_length_admin_users |
Mapped[int]
|
Min password length for admin users. |
Source code in backend/app/server_settings/models.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 | |
ServerSettingsRead
Bases: ServerSettingsEdit
Complete server settings response schema for API responses.
Read-only view of all server settings including administrative signup configuration. Used for authenticated endpoints returning complete server configuration.
Source code in backend/app/server_settings/schema.py
290 291 292 293 294 295 296 297 | |
ServerSettingsReadPublic
Bases: ServerSettingsBase
Public-facing schema for unauthenticated server settings access.
Provides only public-safe server settings, excluding sensitive configuration like signup requirements. Used for the public API endpoint that doesn't require authentication.
Inherits all safe fields from ServerSettingsBase but explicitly excludes admin-level configuration fields.
Source code in backend/app/server_settings/schema.py
300 301 302 303 304 305 306 307 308 309 310 | |
TileMapsTemplate
Bases: BaseModel
Schema representing available tile map templates.
Attributes:
| Name | Type | Description |
|---|---|---|
name |
StrictStr
|
Human-readable name of the tile map template. |
url_template |
StrictStr
|
URL template for fetching map tiles. |
attribution |
StrictStr
|
HTML string for map attribution. |
requires_api_key_frontend |
StrictBool
|
Indicates if an API key is required on the frontend to use the tile map. |
requires_api_key_backend |
StrictBool
|
Indicates if an API key is required on the backend to use the tile map. |
Source code in backend/app/server_settings/schema.py
313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 | |
Units
Bases: Enum
An enumeration representing measurement units.
Attributes:
| Name | Type | Description |
|---|---|---|
METRIC |
Metric system (e.g., meters, kilograms). |
|
IMPERIAL |
Imperial system (e.g., miles, pounds). |
Source code in backend/app/server_settings/schema.py
22 23 24 25 26 27 28 29 30 31 32 | |
edit_server_settings
edit_server_settings(server_settings, db)
Update server settings in database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
server_settings
|
ServerSettingsEdit
|
New settings to apply. |
required |
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
ServerSettings
|
Updated ServerSettings instance. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If settings not found or database error. |
Source code in backend/app/server_settings/crud.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 | |
get_server_settings_db
get_server_settings_db(db)
Retrieve singleton server settings from database.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
ServerSettings | None
|
ServerSettings instance or None if not found. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If database error occurs. |
Source code in backend/app/server_settings/crud.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | |
get_server_settings_or_404
get_server_settings_or_404(db)
Get server settings or raise 404.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
db
|
Session
|
Database session. |
required |
Returns:
| Type | Description |
|---|---|
ServerSettings
|
ServerSettings instance. |
Raises:
| Type | Description |
|---|---|
HTTPException
|
If server settings not found. |
Source code in backend/app/server_settings/utils.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 | |
get_tile_maps_templates
get_tile_maps_templates()
Retrieve a list of tile map templates.
Returns:
| Type | Description |
|---|---|
list[TileMapsTemplate]
|
list[server_settings_schema.TileMapsTemplate]: A list of TileMapsTemplate objects for all tile maps. |
Source code in backend/app/server_settings/utils.py
115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 | |