This commit is contained in:
2026-08-17 11:19:05 -07:00
parent ca0f89a671
commit cf87fdba1a
6 changed files with 199 additions and 5 deletions
+10
View File
@@ -75,6 +75,16 @@ identity_providers:
redirect_uris:
- 'https://mcp.example.com/auth/callback'
# RFC 8707 resource indicators. The MCP server sends a 'resource'
# parameter identifying itself; Authelia validates it against this
# whitelist and returns 'invalid_target' if it isn't listed.
# Alternative: set OIDC_FORWARD_RESOURCE=false on the MCP server to
# stop sending it at all.
audience:
- 'https://mcp.example.com'
- 'https://mcp.example.com/mcp'
requested_audience_mode: 'implicit'
# offline_access is what gets you a refresh token. Without it the
# connector dies when the access token expires.
scopes:
+13
View File
@@ -13,6 +13,19 @@ EnvironmentFile=/etc/bookstack-mcp/env
WorkingDirectory=/opt/bookstack-mcp
ExecStart=/opt/bookstack-mcp/venv/bin/python -m bookstack_mcp
# ProtectSystem=strict makes everything read-only, but the MCP library writes
# to a data directory under $HOME (OAuth client registrations, caches). The
# service user's home is /opt/bookstack-mcp, which is part of the read-only
# tree -- so point HOME and the XDG dirs at directories systemd creates and
# grants write access to. Without this the service dies with
# "OSError: [Errno 30] Read-only file system: '/opt/bookstack-mcp/.local'".
StateDirectory=bookstack-mcp
CacheDirectory=bookstack-mcp
Environment=HOME=/var/lib/bookstack-mcp
Environment=XDG_DATA_HOME=/var/lib/bookstack-mcp
Environment=XDG_CONFIG_HOME=/var/lib/bookstack-mcp
Environment=XDG_CACHE_HOME=/var/cache/bookstack-mcp
Restart=on-failure
RestartSec=5s
TimeoutStopSec=20s
+16 -4
View File
@@ -98,12 +98,24 @@ log "Installing Python dependencies (this takes a minute)"
chown -R "$SVC_USER:$SVC_USER" "$APP_DIR"
# --- Configuration --------------------------------------------------------
# --- Configuration --------------------------------------------------------
# Prefer a filled-in .env if one exists, otherwise fall back to the template.
ENV_SRC=""
for candidate in "$SRC_DIR/.env" "$SRC_DIR/.env.example"; do
[[ -f "$candidate" ]] && { ENV_SRC="$candidate"; break; }
done
[[ -n "$ENV_SRC" ]] || die "Can't find $SRC_DIR/.env or $SRC_DIR/.env.example to seed the config from."
mkdir -p "$CONF_DIR"
if [[ ! -f "$CONF_DIR/env" ]]; then
log "Creating $CONF_DIR/env from the template"
# An empty file counts as "not configured" -- a previous failed run can leave
# a zero-byte config behind, and silently keeping it is worse than replacing it.
if [[ ! -s "$CONF_DIR/env" ]]; then
log "Creating $CONF_DIR/env from $(basename "$ENV_SRC")"
# systemd EnvironmentFile does not understand quotes or inline comments the
# way a shell does, so strip comments and blank lines out of the example.
grep -vE '^\s*(#|$)' "$SRC_DIR/.env.example" > "$CONF_DIR/env"
# way a shell does, so strip comments and blank lines out of the source.
# Write to a temp file first so a failure here can't leave an empty config.
grep -vE '^\s*(#|$)' "$ENV_SRC" > "$CONF_DIR/env.tmp"
mv "$CONF_DIR/env.tmp" "$CONF_DIR/env"
NEW_CONFIG=1
else
log "Keeping existing $CONF_DIR/env"