Skip to content

Single sign-on: one login page for all your applications

Many applications need a login: an internal portal, a dashboard, an admin screen. Building a login yourself is harder than it looks (storing passwords safely, sessions, a second factor, forgotten passwords) and often goes wrong. The server therefore has one built in: Single sign-on, a login page under your own domain where your people log in once for every application you put behind it. Your application does not have to program anything for it.

The Single sign-on page

  1. Enable single sign-on on the Single sign-on page (once). The server starts the login service with a login page under its own name, for example https://login.yourcompany.hddeploy3000.nl.
  2. Add users: the people who may log in. A generated password is shown once; pass it on. Put people in groups (staff, admins) when not everyone may open everything.
  3. Put a stack behind the login: open the stack, tab Access, card Require login. Choose Required (username and password) or Required with a second factor, and deploy the stack. From then on a visitor without a session sees the login page first.

That is all. Every application you protect this way uses the same login; whoever is logged in to one is logged in to the others.

The login sits in front of the application, in the web gateway. A request that reaches your application already comes from a logged-in user, and carries headers that say who:

Header Content
Remote-User the username
Remote-Groups the groups, comma-separated
Remote-Email the e-mail address
Remote-Name the full name

An application that wants to know who is there reads those headers; an application that only has to be “closed” does nothing at all. When you ask your assistant to build an application, say: “the platform handles the login, read the user from the Remote-User header”.

The Single sign-on page, tab Users: add, change name and e-mail, groups, disable (the person can no longer log in, the account stays), reset the password, remove. A user logs in with username or e-mail address and can change their own password on the login page.

Groups are free names. On a stack’s Require login card you can name the groups that may open the stack (empty = everyone who can log in). The application sees the groups in Remote-Groups and can attach rights to them itself (for example: only admins see the admin screen).

Second factor. A user can register an authenticator app (TOTP) or a security key on the login page. The login service mails a confirmation code for that, which only works when the server has a mail relay (HD Services configures it). Without mail it stays at passwords; the page says so.

A login page belongs to a domain: for an application on portal.yourcompany.nl that is login.yourcompany.nl. When you put a stack with such an address behind the login, the server adds that domain and names the login page. The address has to exist, though: a DNS record for login.yourcompany.nl pointing to this server, which HD Services creates for you (helpdesk@hdservices.nl). The Domains table on the page shows whether it is in place yet. For addresses under the server’s own name (something.yourcompany.hddeploy3000.nl) the server creates the record itself.

Applications with their own login button (OpenID Connect)

Section titled “Applications with their own login button (OpenID Connect)”

Most applications are fine with the login in front of the door. An application that wants a real identity (a “Sign in” button, a user profile, a framework such as Auth.js/NextAuth or Laravel Socialite) is registered under Applications: name, the redirect URIs the login sends the user back to, and whether a second factor is required. You get an issuer (the login page of the domain), a client id and a client secret that is shown once. Those three go into the application’s configuration as a generic OpenID Connect provider with the scopes openid profile email groups; the claims are sub (username), name, email and groups.

Microsoft accounts instead of passwords (Microsoft Entra)

Section titled “Microsoft accounts instead of passwords (Microsoft Entra)”

When HD Services has connected your organisation’s Microsoft Entra tenant to your server (the same connection that lets your colleagues log in to this portal with their Microsoft account), a stack can require a Microsoft account of your organisation instead of an account kept on the server: the stack’s Access tab offers it as a third choice next to the password login. Visitors then sign in with their work account, with your organisation’s own multi-factor authentication, and the application receives X-Auth-Request-Email (the account’s address), X-Auth-Request-User and X-Auth-Request-Groups instead of the Remote-* headers.

Who of the organisation gets in is one setting for the whole server, on the Microsoft Entra tab of the Single sign-on page: every account of the organisation, members of groups (by object id), or a list of addresses. Public paths of a stack (webhooks, health checks) stay open as before. Each domain gets a sign-in service on its login host (login.yourcompany.nl/oauth2/...), for which HD Services registers the callback address shown on the tab. A second factor and self-service password reset are your organisation’s business there (Conditional Access), not the server’s. Should the Microsoft connection be removed while a stack still requires it, a deploy of that stack is refused with the reason until the stack’s login requirement is changed: an application is never published without its sign-in.

Through the API, an assistant and the command line

Section titled “Through the API, an assistant and the command line”

A connected assistant can do all of this (scopes sso.read and sso.manage, both in the recommended set): get_sso, enable_sso, add_sso_user, update_sso_user, reset_sso_password, remove_sso_user, set_stack_sso, add_sso_app, remove_sso_app. Its instructions tell it to use the built-in login as soon as you ask for one, and to make webhook and API paths public. REST: GET /sso, POST /sso/enable, /sso/users, /sso/apps, GET/PUT /stacks/{name}/sso, GET/PUT /sso/entra. Command line: hddeploy sso status|enable|user|app|entra and hddeploy stack sso NAME --mode login (or --mode entra). The Microsoft mode has get_sso_entra and set_sso_entra_access; the assistant’s instructions tell it to use it when it is available and the user asks for their own Microsoft accounts.

Prompts that work: “Put the intranet behind the built-in login; only the group staff may enter; /api/webhooks must stay open.” - “Create a user for Jan Jansen (jan@yourcompany.nl) in the group staff and give me his password.” - “Register my Next.js portal as an OpenID Connect application and put the details in the stack’s .env.”