Warda-DNSDocs Warda: from ward — to protect, guardian
v0.9.3

Users of the directory

Business → Users of the directory (business.identity, Warda Business, beta; internal/directory, internal/admin/directory.go, go-ldap v3, MIT): the people of Active Directory or of an LDAP directory (OpenLDAP, Samba…) imported every hour as people of Warda; from 0.8.2 the people of Microsoft Entra ID and of Google Workspace too, and every person of the directory signs in to Warda (see Sign-in of the people of the directory).

  • The directory: Address ldaps://server (port 636) or ldap://server (port 389) with StartTLS — never in clear; the Certificate of the authority (PEM) when the directory has the company's own (the certificate of the server is always checked, one that cannot be checked is refused); the Account of reading (a DN or user@domain, read-only; empty: anonymous) and its password (kept with these settings in the meta table of the database of the box — not encrypted apart, only as the whole database is at rest —, never given back by the API nor put in the diagnostic, in the backups, which are encrypted, and sent to the secondary of a pair of high availability with the rest of the configuration: "Kept: leave empty to keep it"); Where the people are (base DN); the Attribute of the groups (memberOf); the Filter of the people (empty: the people of Active Directory, not its machines, and the inetOrgPerson of OpenLDAP). Each request waits 30 seconds at most.
  • Test the connection reads without importing ("The connection works: 12 people found, 1 disabled (…)"), with the groups seen.
  • Import now, and every hour while Import the people every hour is on (task Users of the directory, business.identity, 5 minutes after the start): a new entry becomes a person (an adult; its name, else its name and login when taken), a person known is renamed with the directory and keeps everything else; the accounts disabled in the directory are marked Disabled in the directory, those no longer found No longer found. Nothing is ever written to the directory, and nobody is removed by itself: Remove the people no longer found asks first (their devices stay, given to nobody).
  • Groups of the directory: give a group of the directory (up to 200) a group of devices; the devices of its people then follow the blocked services and the data loss prevention of that group (their own settings still first; the first group of a person that has one counts). Applied at once.
  • The administration log records directory.settings, directory.sync ("12 found, 2 new, 1 disabled, 0 no longer found") and the people created or renamed (person.create, person.update, "(directory)"). The settings (password included: the backup is encrypted) and the people imported go with the backups.

GET /api/v1/business/identity (accounts read) gives the settings (enabled, url, start_tls, ca, bind_dn, base_dn, filter, group_attribute, groups of dn and group_id; never the password: password_set), status (last, last_ok, error, found, added, disabled, missing), people, seen_groups and every_s; PUT saves them (password empty keeps the one saved); POST /api/v1/business/identity/test tests the settings given (found, disabled, sample, groups); POST /api/v1/business/identity/sync imports now and DELETE /api/v1/business/identity/missing removes the people no longer found (both also need household written). From 0.8.2 the import and the removal take the people of every source (the directory, Entra ID, Google), each marked missing on its own.

Sign-in of the people of the directory#

From 0.8.2 (business.identity, Warda Business, beta: open to every installation during the beta; internal/admin/signin.go, internal/auth, internal/oidc, internal/directory). Card Sign-in to Warda of the page Users of the directory. Before, the people of the directory were imported but nobody could sign in with the directory.

Who signs in, and how. A person of the directory (imported from the directory, Entra ID or Google) signs in with:

  • their own password of the directory (AD or LDAP), typed in the usual form of the sign-in page, with their usual login (sAMAccountName, uid, userPrincipalName or the address of mail); the page says "People of the company: your usual login and password.";
  • Sign in with Microsoft (Microsoft Entra ID) or Sign in with Google (Google Workspace), the buttons of the sign-in page.

At the first sign-in Warda makes an account of the source directory, linked to the person: its name is the login (or what comes before @), never admin, with -2, -3… when taken. It has no password of its own: its password cannot be changed nor reset in Warda (403; the page My account says "Your password is the one of your company: change it there (directory, Microsoft or Google). Warda never keeps it."), and Access to Warda shows the badge Directory and no New temporary password. Its role is given again at each sign-in: the groups of the person in the directory are given groups of accounts under Rights of the groups; the group Administrators makes an administrator; without a group given, the person signs in as a member, or is refused when Only the people of a group given below may sign in is on. A change of the groups in the directory applies at the next sign-in (the sessions open keep their rights until then). The second step of Warda (TOTP) still applies when the person turns it on, after the provider.

Refused: a person disabled in the directory, no longer found, not imported yet (the people are imported every hour: Import now on the page; no import at the sign-in), a name that matches several people, a person linked to an account of Warda (they sign in with that account), the guests of other organisations in Entra ID, the Google accounts outside the domain. When an import finds a person disabled or no longer found, the sessions of their account of the directory end at once.

Break-glass. The accounts of Warda (the emergency account admin first) always sign in with their own password: a name that is an account of Warda never goes to the directory, even when the directory would accept it. The changes of the accounts that ask the password again ("confirm your password") take the password of the directory of a person of AD or LDAP (checked by a bind); a person who signs in only with Microsoft or Google cannot make them (403 with the reason): an account with a password must.

The password of the directory uses the settings of the directory above (LDAPS or StartTLS, the certificate of the server always checked). The account of reading finds the one entry, under the base and the filter, whose sAMAccountName, uid, userPrincipalName or mail is the login (escaped as RFC 4515 asks); Warda then binds as that entry with the password typed, and never keeps it. An empty password is refused before anything (an LDAP bind without password is anonymous), and so is a password with a NUL character. Any refusal of the directory (wrong password, account disabled, locked or expired) answers "wrong user name or password"; a directory that does not answer, 503 "the directory of the company does not answer" (the page: "The directory of the company does not answer. Try again in a moment, or ask an administrator."). At most 4 sign-ins ask the directory at once; the wrong passwords are counted as those of the accounts of Warda (by name and address, /64, by name; see First sign-in). A name that is not an account of Warda costs the same hash of a password as one that is, before the directory is asked: the time of the answer does not tell the names of the accounts of Warda.

Microsoft Entra ID and Google Workspace (OpenID Connect). The flow of the authorization code with PKCE (S256), a state of 256 bits used once, valid 10 minutes and bound to the browser by the cookie warda_signin (Secure, HttpOnly, SameSite=Lax, path /api/v1/sign-in/, cleared on return), a nonce checked in the ID token; the secret of the client goes from the box to the provider, never through the browser. The ID token is checked by Warda itself: RS256 only (never none nor HMAC), the key from the provider's keys (kept an hour, asked again for an unknown key at most every 30 seconds, RSA of 2048 bits or more), the issuer exact, the audience the client ID (azp checked when present), the times with 2 minutes of clock skew, issued less than 10 minutes before. The addresses of the providers are fixed in the code (no discovery, no redirection followed).

  • Microsoft: https://login.microsoftonline.com/<tenant>/oauth2/v2.0/…; the Tenant ID must be a GUID (never common, organizations nor a domain), and the token must name that tenant (tid), not a guest of another organisation. The person is found by its object ID (the people imported from Entra ID) or by preferred_username, the UPN, against the mail, the UPN or the login of a person imported from AD (hybrid); the email claim, which Entra does not verify, is never used. The global Azure cloud only.
  • Google: the domain of the token (hd) must be the Domain set, the address verified and in that domain. The person is found by the Google ID (the people imported from Google) or by the address. One domain of Workspace only.
  • Redirect URI: https://<public name of the box>[:port]/api/v1/sign-in/{microsoft|google}/callback, shown on the card to copy. The public name is the name of the certificate of the box (xxxxxxxxxx.warda-dns.net given by Warda, your own domain, or an imported certificate; see Encrypted DNS for the devices). With a self-made certificate there is none: the card says "Warda has no public name yet…" and the buttons are not shown. A sign-in started on another name (http://warda, an address) is sent to the public name first, so that the cookie and the return are on the same name.
  • The return: the box answers with a small page that leads to / or to /?signin=<code> (expired, refused, provider, locked, busy, unavailable), a fixed target; the sign-in page tells it in the language of the person ("Your account is not allowed to sign in to Warda. Ask an administrator."…). The cookie of the session stays SameSite=Strict.
  • Limits against abuse: 10 sign-ins under way at most per IPv4 address or IPv6 /64, 512 in all (when full, the oldest under way gives its place); the returns are counted with the wrong passwords of the address. The administration log records each success (auth.login "<address> (microsoft)", "(google)", "(directory)") and each failure (auth.failure "microsoft: <names>: <reason>").

The people of Entra ID and Google Workspace (optional: Import the people of Entra ID every hour, Import the people of Google Workspace every hour), with the import of the directory (task Users of the directory, and Import now), each source apart (an import of Entra ID never marks the people of LDAP missing, and a source that fails leaves the others imported; the page tells each error, "Microsoft Entra ID: users (Microsoft Graph): HTTP 403 …"):

  • Entra ID: Microsoft Graph with the token of the same application (client credentials): the users (guests left out; accountEnabled false is disabled), up to 500 groups and their direct members; a group is named "Display name (object ID)", since two groups can share a name. Ids entra:<object ID>.
  • Google: the Directory API with a service account (its JSON key) given the domain-wide delegation of admin.directory.user.readonly and admin.directory.group.readonly, acting as an administrator of the domain (read only): the users (suspended or archived: disabled), up to 500 groups by their address and their members. Ids google:<id>.
  • Bounds: 10,000 people, 500 groups, 200 pages per list, 15 seconds per call, 10 minutes per import of a source, 16 MiB per answer; the links to the next page are followed only under the address of the API (the token never goes elsewhere). Groups: direct members only (as memberOf of AD).

Settings and secrets. Kept in the meta table (directory_signin, JSON) like the password of the account of reading: encrypted with the whole database, in the encrypted backups, given to the secondary of a pair with the configuration; never given back by the API (only microsoft_secret_set, google_secret_set, service_account_set and the address of the service account), the diagnostic or the logs. A secret left empty is kept only for the same tenant and client (Microsoft), domain and client (Google), domain and administrator (the service account). Saving asks the password of the signed-in account again ("Save how the people of the directory sign in, and the rights of their groups?"): the settings decide who becomes administrator. They follow the delegation of Roles: only an account that has every right of the groups of accounts mapped, in the settings saved and in the new ones, saves them (403 otherwise).

Limits. Not tried yet against the real services of Microsoft and Google (the tests use a provider and a directory made for them); to check on a real tenant: the sign-in, the guests refused, the import of Graph, the delegation of Google, and that the Google ID of the Directory API is the sub of the token (if not, the match by address still works). Not done: the national clouds of Entra, several domains of Google, nested groups, the groups in the tokens (the groups come from the import or LDAP), SCIM, an import at the sign-in. The directory answers a login it does not know faster (one search) than one it knows (a search and a bind). An administrator of Entra who can rename UPNs can take a person of AD not synchronised to Entra through the hybrid match: prefer importing the people of Entra. The people behind one NAT share the limits of an address. A person deleted from Warda keeps the sessions of their account of the directory until they end.

API:

Route Body and answer
GET /api/v1/business/identity/sign-in (accounts read) the settings without the secrets, origin, microsoft_redirect, google_redirect, directory_set
PUT /api/v1/business/identity/sign-in (accounts written, confirm_password) {"password": bool, "require_group": bool, "roles": [{"group": "<DN, Entra 'Name (id)' or Google group address>", "account_group_id": n}], "microsoft": {"enabled", "tenant", "client_id", "client_secret", "sync"}, "google": {"enabled", "domain", "client_id", "client_secret", "sync", "service_account", "admin"}}; 403 when the rights mapped are beyond those of the account
GET /api/v1/sign-in/{microsoft|google} (public) starts a sign-in (to the provider)
GET /api/v1/sign-in/{microsoft|google}/callback (public) the return of the provider
GET /api/v1/session (signed out) sign_in: ["directory", "microsoft", "google"], as set
POST /api/v1/session may answer 503 when the directory does not answer

The accounts carry source (directory for an account of the directory) in GET /api/v1/accounts.

Setting up the sign-in, step by step#

Microsoft Entra ID

  1. In Warda, Network → DNS services: the box needs the name of its certificate (for example k3x9abcdef.warda-dns.net). Copy the Redirect URI to register shown in the part Microsoft Entra ID of the card Sign-in to Warda.
  2. Entra admin center → Identity → Applications → App registrations → New registration: name "Warda", Accounts in this organizational directory only (single tenant), Redirect URI: platform Web, paste the URI; Register.
  3. Overview: copy the Directory (tenant) ID into Tenant ID and the Application (client) ID into Client ID.
  4. Certificates & secrets → New client secret: copy its Value (not its ID) into Client secret. Note when it expires and renew it before: the sign-in stops then.
  5. Token configuration: nothing to add (Warda uses the UPN, preferred_username, never the email claim).
  6. Recommended: Enterprise applications → Warda → Properties → Assignment required = Yes, then assign the users or groups who may use Warda.
  7. To import the people (optional): API permissions → Add a permission → Microsoft Graph → Application permissions: User.Read.All and GroupMember.Read.All, then Grant admin consent; tick Import the people of Entra ID every hour.
  8. Import now, then give the groups of Entra ID (or of AD for the people of a hybrid directory) a group of accounts under Rights of the groups.
  9. Tick Show “Sign in with Microsoft” and Save (your password is asked).

Google Workspace

  1. As step 1 above, with the Redirect URI to register of the part Google Workspace.
  2. Google Cloud console (a project of the organisation) → APIs & Services → OAuth consent screen: user type Internal, app name "Warda", the scopes openid, email and profile.
  3. Credentials → Create credentials → OAuth client ID: type Web application, Authorised redirect URIs: paste the URI. Copy the Client ID and the Client secret into Warda, and type the Domain of Workspace (example.com). Google wants a public ending in the redirect URI: the name warda-dns.net is one.
  4. To import the people (optional): enable the Admin SDK API in the project; IAM & Admin → Service accounts → Create service account; Keys → Add key → JSON (the file is downloaded); note the numeric Client ID of the service account. Google Admin console → Security → Access and data control → API controls → Domain-wide delegation → Add new: that Client ID, the scopes https://www.googleapis.com/auth/admin.directory.user.readonly,https://www.googleapis.com/auth/admin.directory.group.readonly. In Warda: tick Import the people of Google Workspace every hour, paste the JSON key into Key of the service account (JSON), and type in Administrator of the domain the address of an administrator of the domain (the service account acts as them, read only).
  5. Give the groups of Google (shown by their address) a group of accounts, as for Microsoft; tick Show “Sign in with Google” and Save.

The password of AD or LDAP

  1. The directory set above (LDAPS or StartTLS) and imported; tick Sign in with the password of the directory and Save.
  2. The people type their usual login (sAMAccountName, UPN or address) and password on the sign-in page of Warda.