mirror of
https://github.com/iflytek/skillhub.git
synced 2026-08-27 11:14:59 +00:00
Deployments that only allow third-party sign-up can now disable local registration end to end: the register endpoint returns 403 when skillhub.auth.local.registration-enabled is false, and the web UI hides the entry when SKILLHUB_WEB_REGISTRATION_ENABLED is false. Also log OAuth2 login failures so callback errors are diagnosable from server logs. Fixes the runtime-config entrypoint so registration defaults are actually exported to envsubst. Signed-off-by: yhd <yhd4711499@live.com>
31 lines
1.7 KiB
Bash
31 lines
1.7 KiB
Bash
#!/bin/sh
|
|
set -eu
|
|
|
|
: "${SKILLHUB_WEB_API_BASE_URL:=}"
|
|
: "${SKILLHUB_PUBLIC_BASE_URL:=}"
|
|
: "${SKILLHUB_WEB_AUTH_DIRECT_ENABLED:=false}"
|
|
: "${SKILLHUB_WEB_AUTH_DIRECT_PROVIDER:=}"
|
|
|
|
# Session-bootstrap variables are defaulted here so envsubst writes
|
|
# `authSessionBootstrapEnabled: "false"` into runtime-config.js instead of leaving
|
|
# the literal `${...}` placeholder. They are intentionally NOT exposed in
|
|
# compose.release.yml or .env.release.example: the matching server-side switch
|
|
# does not exist yet, so surfacing the toggle would let the frontend hit
|
|
# /api/v1/auth/session/bootstrap and receive 403. See PR #280 discussion.
|
|
: "${SKILLHUB_WEB_AUTH_SESSION_BOOTSTRAP_ENABLED:=false}"
|
|
: "${SKILLHUB_WEB_AUTH_SESSION_BOOTSTRAP_PROVIDER:=}"
|
|
: "${SKILLHUB_WEB_AUTH_SESSION_BOOTSTRAP_AUTO:=false}"
|
|
# NB: `${VAR:=default}` only sets a shell variable, not an exported one, so
|
|
# envsubst would still substitute an empty string. Assign and export explicitly.
|
|
SKILLHUB_WEB_REGISTRATION_ENABLED="${SKILLHUB_WEB_REGISTRATION_ENABLED:-true}"
|
|
export SKILLHUB_WEB_REGISTRATION_ENABLED
|
|
|
|
# Generate runtime-config.js
|
|
envsubst '${SKILLHUB_WEB_API_BASE_URL} ${SKILLHUB_PUBLIC_BASE_URL} ${SKILLHUB_WEB_AUTH_DIRECT_ENABLED} ${SKILLHUB_WEB_AUTH_DIRECT_PROVIDER} ${SKILLHUB_WEB_AUTH_SESSION_BOOTSTRAP_ENABLED} ${SKILLHUB_WEB_AUTH_SESSION_BOOTSTRAP_PROVIDER} ${SKILLHUB_WEB_AUTH_SESSION_BOOTSTRAP_AUTO} ${SKILLHUB_WEB_REGISTRATION_ENABLED}' \
|
|
< /usr/share/nginx/html/runtime-config.js.template \
|
|
> /usr/share/nginx/html/runtime-config.js
|
|
|
|
# Generate registry/skill.md with actual public URL
|
|
envsubst '${SKILLHUB_PUBLIC_BASE_URL}' \
|
|
< /usr/share/nginx/html/registry/skill.md.template \
|
|
> /usr/share/nginx/html/registry/skill.md
|