Skip to content
Syno Package Land
Language: English

Identity gateway

The identity gateway signs DSM users in to a packaged app’s web UI: anyone signed in to DSM opens the app already signed in. The app keeps its own sign-in, and the gateway never writes into its database.

Users are keyed by DSM uid, never name. The gateway sends the DSM administrator role at sign-in; the app must support role/group mapping, and an app that cannot (such as OpenList JIT) is accepted with that limitation documented.

A native app declares daemon: the gateway starts it as its child and runs as the package account, never root. A container app declares compose, and Container Manager manages the project. Build with the latest public CLI and templates and their pinned SDK/App and UI versions; upgrading only the CLI does not replace an installed App’s helpers.

  1. The browser opens the app on a gateway port and is sent to /webman/3rdparty/<package>/sso/authorize.cgi on DSM’s own address, same host name and scheme, port 5000 (http) or 5001 (https), or DSM’s configured ports.
  2. There it holds the DSM session cookie and fetches the SynoToken; the check verifies the session through authenticate.cgi with cookie, SynoToken and client address, then confirms the account exists and its name still owns the uid, refusing a deleted account even when DSM still accepts its session.
  3. A signed result, valid for one minute and only for that browser and address, returns the user to the app in the declared mode.

A browser not signed in there to DSM gets a link to DSM, then opens the app again.

ModeUse it whenWhat the app receives
noneKeep the upstream App login; DSM access policy stays separateNo injected identity
oidcThe app supports OpenID Connect sign-inAn embedded provider on 127.0.0.1 with discovery, authorize, token, JWKS and userinfo
headerThe app trusts a user header from a reverse proxyThe headers you name, on every signed-in request
tokenThe app has its own API to create a sessionHeaders your adapter program returns

<sdk-version> is a placeholder, not manifest syntax. synopkgland init copies compatible SDK pins from the locally installed templates. For a manual configuration, query npm view @synopackageland/sdk version, replace the placeholder with that exact release, and keep all App SDK declarations (including Go, Rust and frontend dependencies) aligned. Run synopkgland check with an up-to-date CLI before building.

identity_gateway:
sdk: <sdk-version>
mode: oidc
upstream: 8000
listen: {http: 18080, https: 18443}
roles: {claim: groups, admin: administrators, user: users}
oidc:
issuer_port: 18090
clients:
- id: paperless
redirect_paths: [/accounts/oidc/dsm/login/callback/]
pkce: true
redirects:
/accounts/login/: /accounts/oidc/dsm/login/

Configure the app’s OpenID Connect client with:

SettingValue
Issuer$SYNOPKGLAND_SSO_ISSUER = http://127.0.0.1:<issuer_port> (discovery)
Client IDThe client id
Secret$SYNOPKGLAND_SSO_SECRET_<ID>: the id upper-cased, - and . as _ (e.g. SYNOPKGLAND_SSO_SECRET_PAPERLESS)
Redirect URIThe app’s address plus one redirect_paths entry
Scopesopenid profile email, plus groups for the role

Read both in the daemon’s start program and place them where the app expects its OIDC settings.

The browser never reaches the issuer port: the app’s redirect to http://127.0.0.1:<issuer_port>/authorize becomes /_sso/authorize on the opened address, and only that path; OIDC token, JWKS and userinfo calls stay on loopback.

ClaimValue
subThe DSM uid
preferred_username, nameThe DSM account name
emailGenerated from the account name at email_domain (default nas.invalid), lower-cased, or uid-<uid>@... if not a plain address; email_verified is true. Never typed by a user
groups[<roles.admin>] for a DSM administrator, else [<roles.user>] or []; another roles.claim holds it

A redirect URI must be exactly the opened address plus one redirect_paths entry; other hosts, schemes, ports, paths and unknown clients are refused. pkce: true requires an S256 code challenge. redirects sends the app’s sign-in page to its OIDC start; keep a password route for the app’s local administrator if needed.

identity_gateway:
sdk: <sdk-version>
mode: header
upstream: 3923
listen: {http: 13980, https: 13943}
headers: {user: Remote-User, groups: Remote-Groups, email: Remote-Email}
roles: {admin: admin, user: users}
passthrough: [/pub/]

Every signed-in request carries user (account name), email, name, uid and groups (the role), after removing browser copies so nobody can impersonate another user; trust the header only from 127.0.0.1.

Without a gateway session a page load redirects to sign-in and anything else gets 401 {"error":"dsm_sign_in_required"}; same-origin POST /_sso/logout ends the session.

identity_gateway:
sdk: <sdk-version>
mode: token
upstream: 5244
listen: {https: 15244}
token: {exec: bin/session-adapter, args: [--mint]}

After sign-in the gateway runs token.exec from the daemon payload as the package account with SYNOPKGLAND_SSO_UID, SYNOPKGLAND_SSO_USER and SYNOPKGLAND_SSO_ADMIN (1/0); the program mints that session through the app’s API and prints {"headers": {"Authorization": "Bearer ..."}}, added until the session ends.

The gateway replaces browser-sent X-Forwarded-For and X-Real-IP with the client address, X-Forwarded-Proto with http/https and X-Forwarded-Host with the opened host, and removes X-Forwarded-Port, X-Forwarded-Prefix, X-Original-URL, X-Rewrite-URL and its own cookies; trust them from 127.0.0.1 so links use the opened address.

upstream_access: public requires mode: oidc: access still protects the DSM OIDC issuer, while the upstream owns App authentication, authorization, CSRF and WebSocket policy; native clients need no DSM cookie or browser Origin, and DSM logout or account removal does not revoke the upstream session.

launch_path sets a fixed local path, query or SPA fragment for the DSM menu entry (e.g. /#/sso?identifier=fixed-organization), keeping the DSM hostname and public port; absolute URLs, network paths, traversal and reserved /_sso paths are refused. Default /; it neither signs in nor unlocks encrypted data.

oidc.browser_redirect: {} opens one installed App through its IP, hostname or a DNS alias: redirects derive from the validated request authority, and the SPK holds no host list. Loopback endpoints, DSM admission, PKCE and exact callback paths still apply; html_paths limits rewriting and same_origin_referrer: true supports native forms. Cookies stay host-only, so each origin needs its own DSM sign-in; use trusted DNS and TLS.

identity_gateway:
sdk: <sdk-version>
mode: oidc
access: dsm-admins
oidc:
native_login: true
browser_redirect: {}

Server-managed OIDC without a browser bridge

Section titled “Server-managed OIDC without a browser bridge”

Leave oidc.browser unset and set oidc.native_login: true for an upstream that already redirects to its OIDC provider and runs its own callback: native DSM sign-in and bounded cold-launch resume, independent of HTML/SPA injection; use the browser bridge only when navigation needs the declared start, login, callback or completion handling. Forwarded host, scheme and port derive from validated public authority, so callback/logout URLs can use a nonstandard gateway port; never trust client forwarding headers.

ui: false suits a native App whose only UI is behind identity_gateway: the DSM menu opens sso/open.cgi in a new tab, Package Center Open uses it too, and the SPK has one URL launcher, no SDK window or frontend bundle.

It requires identity_gateway and excludes console, portal and capabilities.rootOps, delegate, webapi or identity, whose approval or sign-in needs the window; check reports STANDALONE_UI_NO_WINDOW_INVALID and inspect verifies the launcher and INFO adminurl.

For a native daemon the app must listen on 127.0.0.1:<upstream> only; otherwise anyone skips the gateway, or in header mode sends the user header themselves. check cannot see its listen address, so set it in the app’s configuration and test from another computer.

Compose uses schema-2 dsm-package.yaml with upstream files, a generated override and the SDK planner, with no dummy CGI, helper directory or wrapper container; the gateway dials the declared container port on a dedicated internal bridge, with no published ports and no loopback host_port or upstream. Declare App health and see Container apps for readiness and subnet conflicts.

Mode none keeps native app login; other modes use the embedded gateway and account bridge, with no SSO Server. Browser mutation/WS requests need exact Origin/Referer, upstream POST needs no SynoToken, and only DSM id/did and SDK cookies are filtered.

Containers use a fixed package identity and do not inherit the user’s File Station ACL; per-user file access belongs to a session/Broker Adapter outside this feature. App privilege denial returns HTTP 403 with package-specific guidance (access_denied, error_reason=app_privilege_denied; the gateway displays dsm_app_privilege_denied). A waiting_ready daemon opens no upstream ingress before host health succeeds.

passthrough lists prefixes forwarded without a DSM session or identity headers, for public share links, WebDAV and mobile-app API clients, protected by the app’s own authentication; every other path needs the gateway session in header and token modes, while oidc mode forwards all paths under the app’s own session.

With matching SDK and CLI releases and os_min_ver set to 7.2-64570 or later, the CLI provides HTTPS through DSM’s web-config nginx and its default certificate: the browser must already trust that certificate and it must match the opened hostname or a warning appears. No public certificate is acquired and DSM’s private key is never read or copied, and a desktop certificate exception or Login Portal assignment does not change the system default certificate used here.

listen.https is the entry: with only listen.http that port serves HTTPS, and when both ports differ HTTP 308-redirects to HTTPS. DSM nginx reaches the package-account gateway over a private Unix socket with mutual TLS, preserving admission, client address binding, Secure cookies and WebSocket checks without root for the App.

Without native DSM HTTPS from the matching SDK: direct connection, a possible warning for the self-signed certificate, and unencrypted HTTP on trusted networks only; a native worker or private TLS failure stops install or startup rather than downgrading. Linux gate coverage does not establish DSM device acceptance at the minimum version.

prestart waits up to 15 seconds for retiring TCP listeners on the declared ports before DSM acquires web-config; DSM logs record NATIVE_GATEWAY_PORT_WAIT and NATIVE_GATEWAY_LIFECYCLE, and a stuck port needs those logs.

In header and token modes every request rechecks that the account name maps to the same uid, so a deleted or renamed account loses its session at once. Signing out of DSM does not end an existing session, which lasts until session_ttl (the app decides in oidc mode), so choose a short session_ttl when that matters. A deleted DSM account cannot sign in; see Deleted DSM accounts.

Declare account.on_delete to remove a deleted account’s data; everything runs as the package account, with no root, DSM hook or DSM polling.

identity_gateway:
# ...
account:
on_delete:
- remove: users/{uid}
- exec: [bin/myapp, user, delete, "{name}"]
ActionWhat it does
remove: <path>Recursively removes a relative path under /var/packages/<package>/var, naming the account with {uid} or {name} and not under sso/; never follows a symlink out of var, and a missing path counts as removed.
exec: [<program>, args...]Runs a daemon-payload program without a shell with SYNOPKGLAND_SSO_UID and SYNOPKGLAND_SSO_USER; {uid} and {name} are replaced only in arguments. One minute; exit 0 is success.

Actions run in order and stop at the first failure. The gateway records each uid that signs in, with its name and whether it is local: it watches /etc for /etc/passwd changes, and a missing recorded uid revokes its gateway sessions and OIDC codes and tokens and runs the actions within seconds; the same check at every start catches deletions made while stopped.

Domain accounts (LDAP or Active Directory) are never deleted automatically, since an outage looks like a deletion; once DSM cannot resolve them they cannot sign in. gateway account status lists them and an administrator runs gateway account purge <uid>.

A failed deletion stays pending with its error and is retried after 5 seconds, doubling to 5 minutes, on every start and passwd change.

Terminal window
/var/packages/<package>/target/daemon/payload/_sso/gateway account status [--json]
/var/packages/<package>/target/daemon/payload/_sso/gateway account purge <uid>

Run both as the package account: status prints pending deletions with their last error and unresolvable domain accounts; purge refuses a uid that never signed in or that DSM still knows.

Renaming an account or changing its password or administrator status needs no action, since the uid stays and the role is sent at each sign-in; a disabled account cannot sign in, but an existing app session lasts as the app decides.

PathPurpose
ui/sso/authorize.cgiSign-in check on DSM’s address
daemon/payload/_sso/gatewayThe gateway; your daemon payload must not contain _sso/
sso/gateway.jsonGenerated gateway configuration
/var/packages/<package>/var/sso/Private state (0700): gateway key, client secrets, OIDC signing key, TLS certificate, and with account the recorded uids (seen-uids.json) and pending deletions (pending/), each 0600

build compiles the gateway from the SDK release in sdk with the pinned Go. All fields are in the manifest reference.

ItemValue
Gateway session (header, token)session_ttl seconds, default 3600 (range 60–86400), bound to the client address; cookie synopkgland_sso_<package>, HttpOnly, SameSite=Lax, Secure on https
Sign-in in progress5 minutes, one browser and address
Check result from DSM1 minute, used once
OIDC code, ID token, access token1 minute, 5 minutes, 5 minutes
Token program10 seconds and 64 KiB of output