Authelia
Self-hosted OIDC identity provider with declarative users, OIDC client
aggregation, and access control. Users and OIDC clients are declared via the
generic auth export type — any IdP clan service (Authelia, Kanidm, etc.)
can consume the same exports.
Usage
inventory.instances = {
# 1. Declare users with identity scoped to the IdP instance name ("main")
user-alice = {
module.name = "users";
roles.default.tags.all = { };
roles.default.settings = {
user = "alice";
share = true;
identity.main = {
email = "alice@example.com";
groups = [ "admins" "users" "grafana-users" ];
};
};
};
user-bob = {
module.name = "users";
roles.default.tags.all = { };
roles.default.settings = {
user = "bob";
share = true;
identity.main = {
# email defaults to bob@mail.<meta.domain>
groups = [ "users" "miniflux-users" ];
};
};
};
# 2. Deploy Authelia — instance name "main" matches identity.main above
main = {
module.input = "clan-community";
module.name = "authelia";
roles.default.machines.my-server.settings = {
publicHost = "auth.example.com";
domain = "example.com";
# Optional: restrict specific clients beyond the default group policy
clientAccess = {
grafana = [ "user:alice" ];
};
# Optional: inline OIDC clients for non-clan-service apps
extraClients = {
miniflux = {
redirect_uris = [ "https://news.example.com/oauth2/oidc/callback" ];
scopes = [ "openid" "profile" "email" ];
};
};
};
};
};
Roles
default
The single Authelia server role. Aggregates auth exports from the entire
clan inventory to build its user database and OIDC client list.
Identity scoping
User identities are scoped by IdP instance name. This supports multiple IdP instances in the same clan (e.g. an internal and an external Authelia, or an Authelia + a Kanidm):
identity.internal-auth = {
groups = [ "admins" ];
};
identity.external-auth = {
groups = [ "readonly" ];
};
Each IdP instance only reads identities keyed with its own inventory instance name. Users without a matching identity key don't get an account in that IdP.
OIDC client aggregation
Other clan services declare their OIDC client requirements via the auth
export type. Set manifest.exports.out = [ "auth" ] in your service and emit:
exports = mkExports {
auth.client = {
clientId = "my-app";
clientName = "My Application";
redirectUris = [ "https://my-app.example.com/callback" ];
scopes = [ "openid" "profile" "email" ];
public = false;
};
# Generator definition (without runtimeInputs — added by each nixosModule)
auth.varsGenerator = {
share = true;
files.client_secret = { };
files.client_secret_hash = { };
script = ''
mkdir -p $out
openssl rand -hex 32 > $out/client_secret
authelia crypto hash generate argon2 --password "$(cat $out/client_secret)" \
| sed 's/^Digest: //' > $out/client_secret_hash
'';
};
};
The Authelia service auto-aggregates these into its OIDC clients config.
Access policies
Each OIDC client auto-receives an authorization policy named
<clientId>-policy. By default, this allows users in the
group:<clientId>-users group. Override per client via:
clientAccess— shorthand:clientAccess.grafana = [ "user:alice" ];clientPolicies— escape hatch for raw Authelia policy definitions
Per-user passwords
For each user from the auth.users exports, the service auto-generates a
random passphrase (xkcdpass) plus an argon2 hash. Retrieve the plaintext via:
clan vars get <hostname> authelia-user-<username>/password
Provider-agnostic design
The auth export schema is not Authelia-specific. A future Kanidm or
Keycloak clan service can consume the same auth.users and auth.client
exports, implementing its own mapping to native config. Consuming services
don't need to change when swapping IdPs.