Sign-in and accounts
Keycloak from the ready-made stack, connecting your own OIDC provider, the cloud password, phone numbers and the owner.
Comon stores no passwords of its people. The organization's sign-in service checks who signs in over OpenID Connect (OIDC), and the federation trusts its signed answer. Comon never sees the sign-in password: the app opens the sign-in page in the system browser.
A person in the federation is identified by the pair of the provider's issuer and sub. Email
and username are not keys, so they can change in the provider without consequences.
Keycloak from the ready-made stack
mvp-stack.py prepare creates the comon realm in Keycloak with the comon-federation client:
- authorization code with PKCE S256; the implicit flow and password grant are off;
- one redirect URI:
https://<domain>/auth/oidc/callback; - self-registration and password reset are off;
- brute-force protection is on.
The admin console is at https://<domain>/identity/admin/; the first sign-in is operator with
the password from stack.env (KEYCLOAK_ADMIN_PASSWORD). Create people in the comon realm. To
let people register themselves, enable registration in the realm's login settings and set up email
in Keycloak.
Your own OIDC provider
Any provider with authorization code and PKCE works: Keycloak, Authentik, Zitadel, a corporate
sign-in service. Register a client there with the redirect URI https://<domain>/auth/oidc/callback
and describe it in a JSON file that the server reads through --oidc-config:
{
"issuer": "https://id.example.org",
"client_id": "comon",
"authorization_endpoint": "https://id.example.org/oauth2/authorize",
"token_endpoint": "https://id.example.org/oauth2/token",
"jwks_uri": "https://id.example.org/oauth2/jwks",
"token_endpoint_auth_method": "client_secret_basic",
"client_secret_file": "secrets/oidc-client-secret",
"scopes": ["openid", "profile"]
}| Field | Required | Meaning |
|---|---|---|
issuer | yes | The issuer, exactly as in the token. HTTPS only. |
client_id | yes | The client ID at the provider. |
authorization_endpoint | yes | The sign-in page. HTTPS only. |
token_endpoint | yes | Exchanges the code for tokens. |
jwks_uri | yes | The provider's signing keys. The token's signature is checked (RS256). |
userinfo_endpoint | no | Where to read a verified phone number and name when the token lacks them. |
token_endpoint_auth_method | no | none (default, public client), client_secret_basic or client_secret_post. |
client_secret_file | for client_secret_* | A file holding the client secret, relative to the settings file. A trailing newline is fine. Never put the secret in the JSON itself or on the command line. |
scopes | no | ["openid", "profile"] by default. Must include openid. Add phone to receive verified numbers. |
nonce_mode | no | required (default): the provider must return a nonce. pkce_only is for providers without nonce, with a confidential client only. |
allow_private_http | no | Allow http:// for token_endpoint, jwks_uri and userinfo_endpoint when the provider is on the same internal network. |
The server checks the signature, issuer, audience, token times and nonce. If anything does not
match, the sign-in is refused; pkce_only never switches on by itself after a failed check.
From the token the server takes sub, a name from given_name (as a hint during sign-up) and, when
phone is requested, a verified number (phone_number with phone_number_verified: true).
The issuer is part of every person's identity. Changing the issuer of a running federation is a
migration: stop the server, take a backup and move the mappings in one transaction,
or people get new empty profiles.
Without OIDC
Without --oidc-config the server starts a built-in development sign-in where anyone can sign in as
anyone. It only works locally; behind a TLS proxy (--behind-tls-proxy) the server requires a real
OIDC provider.
Web clients
For sign-in to work in the web client, the server must know its address:
--web-client=https://<domain>/app (repeatable). The sign-in result comes back to
<address>/auth/callback/<nonce>; the redirect URI at the provider stays /auth/oidc/callback.
Cloud password
The cloud password is the second sign-in step on a new device. --profile-password-policy sets
the policy:
| Value | What happens |
|---|---|
required (default) | On the first sign-in a person sets a password. New devices cannot sign in without it. It cannot be removed. |
optional | New profiles sign in without a password. Whoever sets one enters it on new devices until they turn it off in Settings › Privacy › Cloud password. |
Changing the policy does not remove passwords already set. How the password is stored and how many attempts are allowed: security.
Resetting a forgotten password
Stop the server and run from backend/comon_federation_server (needs the Dart SDK; this command is
not in the server image, and it needs access to the federation's PostgreSQL):
dart run bin/reset_profile_password.dart --data=<data directory> --profile=<profile id> \
--postgres-conninfo-file=<file>The command asks for the new password twice (or reads it from standard input with
--password-stdin) and signs out every device of that profile. The password is never passed as
an argument.
Phone numbers
There are no phone numbers by default. The owner turns them on in the app: Manage Federation › Rules and policies › Contacts and phone numbers › Phone numbers.
| Mode | Meaning |
|---|---|
| Off | No numbers and no phone book matching. |
| Optional | The number comes from the sign-in provider when it supplies a verified one, or an administrator enters it on the person's card. |
| Required | Signing in needs a verified number from the provider. Devices already signed in stay. Available only when scopes includes phone. |
The federation owner
The first person to finish sign-up becomes the owner. If there is no owner (for example in an old federation), the profile with the earliest completed sign-in becomes the owner at start. The owner changes in the app or with an offline command (federation settings).
Limits
| What | How many |
|---|---|
| Profiles per server, bots included, call guests not | 10,000 |
| Cloud password | 10 to 128 characters |