woodglue.config¶
YAML-backed server configuration.
YAML-backed server configuration.
The config file lives at {data_dir}/woodglue.yaml and is required to run
the server. It declares storage, namespaces, documentation, UI, and engine
settings.
Identity Provider secrets may be given as ${NAME} environment variable
references. load_config expands them unless called with
expand_secrets=False, which every wgl command that loads the config uses
except wgl start, so an admin can run them without the secrets set.
Logging for wgl start is driven by storage.log_file, storage.log_level,
storage.loggers, storage.log_max_bytes, storage.log_backup_count, and
the optional top-level logging: section; see woodglue.log_setup.
EXPAND_SECRETS = 'expand_secrets'
module-attribute
¶
Validation context key; false leaves provider ${NAME} references as written.
WoodglueStorageConfig
¶
Bases: StorageConfig
Extends lythonic StorageConfig with woodglue-specific storage and log rotation.
log_level defaults to INFO here rather than lythonic's DEBUG.
Source code in src/woodglue/config.py
log_file_explicit
property
¶
Whether log_file was given in the config, including an explicit null
(which disables the file log).
DocsConfig
¶
UiConfig
¶
Bases: BaseModel
Web interface settings. enabled serves the Console at /console/.
default names the UI that / redirects to: console or a key of uis.
Source code in src/woodglue/config.py
UiEntry
¶
Bases: BaseModel
A project UI served at /ui/<name>/, next to the Console. Exactly one of
these says what it is:
path: a Static UI, a directory of built files (relative to the data dir), such as a single-page app built withbase: "/ui/<name>/". Withspa_fallback, paths without a file extension that match no file returnindex.html, so client-side routes survive a reload; a missing.jsfile is still a 404.kind: streamlitwithapp: a Streamlit script that woodglue runs and proxies to (seewoodglue.apps.ui_process).command: any other server that woodglue runs and proxies to. Its arguments may use{port}(a free loopback port woodglue picks) and{base_path}(/ui/<name>); the server must listen on that port and serve under that path.upstream: the URL of a server run elsewhere, proxied to as is. It must serve under/ui/<name>too.
A Process-backed UI (all but path) gets the viewing User's identity in
request headers (see woodglue.ui_support), including a Delegated Token to
call the API as them. grants limits that token to the overlap of the
viewer's Grants and these, e.g. ["call reports", "read reports"], so a
compromised UI process cannot use everything an admin viewer may. Without
grants the token carries all of the viewer's Grants. ready_path is what
woodglue polls until the process answers; dev turns on the framework's
reload.
app and path may name a location in an installed package rather than on
disk, as package:<import name>/<path> (package:cointoss/explorer_app.py),
which keeps the config independent of the environment's location and Python
version. A subpackage is just more path, and the path cannot leave the
package. References are resolved by wgl start and checked by
wgl caddy config (see resolve_package_refs), so a bad one does not
affect commands that do not use UIs. The working directory stays the data
dir or cwd.
Opening any UI needs view on ui:<name> unless public.
Source code in src/woodglue/config.py
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 | |
NamespaceEntry
¶
Bases: BaseModel
Per-namespace configuration. Exactly one of gref, file, or entries
must be set to specify how the namespace is instantiated.
However it is defined, the namespace is built and called with its
woodglue.mount.MountContext set as current_mount. A fragment needing the
instance data dir reads current_mount.get(None).data_dir rather than
taking an absolute path in its init config, so a copied woodglue.yaml
still points at its own instance.
Source code in src/woodglue/config.py
AdmitRules
¶
Bases: BaseModel
Who an Identity Provider may sign in. A person is admitted if any rule
matches. groups matches the provider's groups claim, or for GitHub an org
login (walnutgeek) or team (walnutgeek/core). anyone admits every
person the provider vouches for, which for a public provider such as Google
or GitHub means anyone on the internet.
Source code in src/woodglue/config.py
ProviderConfig
¶
Bases: BaseModel
One Identity Provider in auth.providers.
kind: oidccovers Google, Entra ID, Auth0, Okta, and other OpenID Connect providers;issueris the URL its discovery document hangs off.kind: githubuses GitHub's OAuth2;github_urlandgithub_api_urlpoint at GitHub Enterprise when needed.kind: trusted_proxy_jwttrusts a reverse proxy that signs each request's identity as a JWT inheader, e.g. Cloudflare Access (Cf-Access-Jwt-Assertion), Google IAP (x-goog-iap-jwt-assertion), or oauth2-proxy. The JWT is checked againstjwks_url,issuer, andaudience;email_claimandgroups_claimname the claims to read.kind: trusted_proxy_headertrusts a plainheadersuch asX-Forwarded-Email, with optionalname_headerandgroups_header(comma-separated), but only fromtrusted_sources(IPs or CIDRs). Anyone who reaches woodglue without the proxy can forge the header, sotrusted_sourcesis required.
With a trusted proxy there is no login page: the first request carrying a valid assertion signs the person in and starts a Session.
client_id, client_secret, issuer, and audience may reference
environment variables as ${NAME}, expanded when the config is loaded
unless load_config is told not to (see there). default_roles and the
Roles that group_roles maps a person's groups to are re-applied at every
login, so removing someone from a group takes their Role away at their next
login.
admit_as: pending makes a User this provider's sign-in creates wait for an
admin's approval, holding no Grants until then; people in auth.admins are
still created active. It does not change the status of existing Users,
except that a pending User later added to auth.admins becomes active
at their next sign-in.
Source code in src/woodglue/config.py
305 306 307 308 309 310 311 312 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 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 | |
trust_email = False
class-attribute
instance-attribute
¶
Treat the email claim as verified even without email_verified: true.
Only for providers whose addresses the organization controls, such as a
single-tenant Entra ID, which does not send email_verified.
AuthConfig
¶
Bases: BaseModel
Authentication and authorization settings.
roles maps a Role name to its Grants, written as "<action> <pattern>"
strings (see woodglue.access). The admin Role is built in. When
enabled is false, every request runs as an anonymous Caller with all
Grants.
providers lists the Identity Providers people can sign in with (see
ProviderConfig); with none, the login page takes a Personal Access Token.
People whose verified email is in admins get the admin Role at login.
public_url is the server's address as browsers see it (e.g.
https://wg.example.com), used to build login callback URLs when woodglue
runs behind a proxy; by default it is taken from each request.
Source code in src/woodglue/config.py
WoodglueConfig
¶
Bases: BaseModel
Root configuration loaded from woodglue.yaml.
namespaces maps a prefix string to a NamespaceEntry dict with exactly
one of gref, file, or entries, plus optional expose_api and
run_engine flags.
uis maps a name to a project UI served at /ui/<name>/ (see UiEntry).
logging, when present, is a logging.config.dictConfig dict that replaces
woodglue's default logging setup (see woodglue.log_setup).
Source code in src/woodglue/config.py
is_package_ref(value)
¶
Whether a UI's app or path names a location in an installed package.
Source code in src/woodglue/config.py
package_path(ref, *, directory)
¶
The absolute path of a package:<import name>/<path> reference, which must be
a directory or else a file. The package is located but not imported, and
editable installs work too. Raises ValueError if the reference is malformed
or does not resolve.
>>> package_path("package:woodglue/apps/uis.py", directory=False).name
'uis.py'
>>> package_path("package:woodglue/../secrets.py", directory=False)
Traceback (most recent call last):
ValueError: package:woodglue/../secrets.py: the path must stay inside the package
Source code in src/woodglue/config.py
expand_env(text, env)
¶
Replace ${NAME} references with values from env, so secrets stay out of
woodglue.yaml. A missing variable is an error rather than an empty string.
>>> expand_env("${ID}-x", {"ID": "abc"})
'abc-x'
>>> expand_env("${NOPE}", {})
Traceback (most recent call last):
...
ValueError: Environment variable NOPE is not set
Source code in src/woodglue/config.py
load_config(data_dir, *, expand_secrets=True)
¶
Load WoodglueConfig from {data_dir}/woodglue.yaml.
expand_secrets=False leaves the provider ${NAME} references unexpanded,
for commands that never sign anyone in. Such a config must not reach
create_app or an Identity Provider client.
Raises FileNotFoundError if the file does not exist.
Source code in src/woodglue/config.py
resolve_package_refs(config)
¶
Replace the package: references in config.uis with absolute paths. Raises
ValueError naming the UI if one does not resolve.