fix: bind Moallem auth tokens to correct host

This commit is contained in:
SepehrYahyaee
2026-10-26 16:10:32 +03:30
parent 8d73d4996c
commit 63b1bb3e2c
4 changed files with 75 additions and 12 deletions
+23
View File
@@ -295,6 +295,28 @@ apply_client_auth_defaults() {
esac
}
# Each tenant's authentication token is only valid on the API host that issued
# it. In particular, Moallem uses api.inssw.ir while the other seeded tenants
# use apimanager.iraneit.com. Do not let an inherited API .env or a stale flow
# env file silently send Moallem credentials to the shared host.
apply_client_endpoint_defaults() {
if [[ "$FANAVARAN_CLIENT" != "moallem" ]]; then
return 0
fi
local moallem_api_base="https://api.inssw.ir/BimeApiManager/api"
local moallem_bime_base="$moallem_api_base/BimeApi/v2.0"
if [[ -n "${FANAVARAN_BASE_URL:-}" && "$FANAVARAN_BASE_URL" != "$moallem_api_base" ]]; then
warn "Ignoring FANAVARAN_BASE_URL for moallem; Moallem tokens must use api.inssw.ir"
fi
if [[ -n "${FANAVARAN_BIME_URL:-}" && "$FANAVARAN_BIME_URL" != "$moallem_bime_base" ]]; then
warn "Ignoring FANAVARAN_BIME_URL for moallem; Moallem tokens must use api.inssw.ir"
fi
FANAVARAN_BASE_URL="$moallem_api_base"
FANAVARAN_BIME_URL="$moallem_bime_base"
export FANAVARAN_BASE_URL FANAVARAN_BIME_URL
}
apply_shared_defaults() {
ACCIDENT_CITY_ID="${ACCIDENT_CITY_ID:-701}"
ACCIDENT_REPORT_TYPE_ID="${ACCIDENT_REPORT_TYPE_ID:-155}"
@@ -1042,6 +1064,7 @@ ask_var FANAVARAN_CLIENT "Fanavaran client (parsian|tejaratno|moallem)"
FANAVARAN_CLIENT="${FANAVARAN_CLIENT,,}"
apply_client_auth_defaults
apply_client_endpoint_defaults
apply_shared_defaults
STAGES="$(echo "$STAGES" | tr '[:upper:]' '[:lower:]' | tr -d ' ')"