Environment variables
masks reads its settings from environment variables. This page lists every variable that the server and the development tools read, and points to the SDK pages for the variables each SDK reads.
| Section | What reads it |
|---|---|
| Server | The ghcr.io/masksrb/masks image, or any other way of running server/. |
| SDKs | The libraries your apps use to connect to masks. |
| Development | ./dev, the Compose stack, and the test suites. A deployed server ignores them. |
./dev reference fails when the server or the development tools read a variable that this page
does not list, or when this page lists a variable that nothing reads.
Server
Section titled “Server”The server reads these when it boots. Restart the server after you change one. Every value is
text, so a true or false setting is the text true or false.
| Variable | Default | |
|---|---|---|
MASKS_MODE |
server |
server runs masks as its own app. engine runs it mounted inside another Rails app, with its own database, session, and secrets. config.masks.mode sets the same thing. See engine mode. |
Required in production
Section titled “Required in production”In production, the server does not boot without these. The error names the missing variable.
The container image’s entrypoint (the script that runs when the container starts) derives the first four from one master key. See encryption and secrets.
| Variable | Default | |
|---|---|---|
SECRET_KEY_BASE |
derived | Signs and encrypts sessions and cookies. Rails reads it. |
ENCRYPTION_PRIMARY_KEY |
derived | Encrypts the columns that hold secrets. These are signing keys, authenticator app secrets, provider and sending service credentials, connected accounts’ tokens, stream secrets, pairwise salts, and setup tokens. |
ENCRYPTION_DETERMINISTIC_KEY |
derived | Encrypts columns that masks looks up by value. No column uses it yet. Rails requires it to be set. |
ENCRYPTION_KEY_DERIVATION_SALT |
derived | Used with the two keys above to make a separate key for each column. |
MASKS_MASTER_KEY |
generated | The key the four above are derived from, when you do not set them yourself. Wins over MASKS_MASTER_KEY_FILE when both are set. |
MASKS_MASTER_KEY_FILE |
/rails/storage/master.key |
The file where the entrypoint reads the master key. If the file does not exist, the entrypoint generates a key and writes it there. |
MASKS_PREVIOUS_MASTER_KEY |
none | The master key you used before a rotation. masks can still read columns encrypted with it. The next boot encrypts them again with the current key. Wins over MASKS_PREVIOUS_MASTER_KEY_FILE when both are set. |
MASKS_PREVIOUS_MASTER_KEY_FILE |
none | A file that holds the previous master key. |
ENCRYPTION_PREVIOUS_PRIMARY_KEY |
derived | The primary key derived from the previous master key, when you do not set it yourself. |
In development and test, masks uses keys stored in the source code, and it builds links from the
request’s own Host header. It keeps no origin at setup. A build step that boots the app without serving it skips these checks
with SECRET_KEY_BASE_DUMMY.
Tenants
Section titled “Tenants”A tenant is one separate set of actors, clients, and settings. Each tenant has its own subdomain.
| Variable | Default | |
|---|---|---|
MASKS_TENANTS |
none | Declares Multi tenants. Lists the subdomains this server serves, separated by commas or spaces, such as demo,acme. The image’s entrypoint creates any that do not exist before the server starts. |
MASKS_TENANT |
none | Declares a Single tenant, the only one this server serves. You cannot set it together with MASKS_TENANTS. The image’s entrypoint sets it to masks when MASKS_TENANTS is unset and MASKS_PUBLIC_ORIGIN_TEMPLATE has no %{subdomain}. |
MASKS_PUBLIC_ORIGIN_TEMPLATE |
none | The public origin (the scheme and host) of each tenant. %{subdomain} stands for the tenant’s subdomain, as in https://%{subdomain}.auth.example.com. A template without %{subdomain} serves every tenant from one host. masks builds the issuer, the registration endpoint, and every link in an email from it. The server answers only hosts that match it and tenants’ custom domains. Every other host gets a 404. Without it, each tenant keeps the origin its Set up screen was opened at, and answers only there. See the public address. |
MASKS_CONFIG |
none | A YAML file of apps, groups, and tenant settings. masks applies it on every boot. See declaring apps in a file. |
MASKS_METRICS_TOKEN |
none | Turns on /metrics for Prometheus. /metrics then answers only a request that carries this token. See metrics. |
MASKS_ON_DEMAND_TLS |
false |
true opens /tls/allowed, which a proxy asks before it issues a certificate for a tenant’s custom host. It answers from the server’s own address, outside the hosts MASKS_PUBLIC_ORIGIN_TEMPLATE allows. See certificates on demand. |
MASKS_RECOVER |
none | Gets someone back into an account when nobody else can. For example, the only manager has lost their second factor. Name the account by nickname or email address. To pick one tenant, write tenant/nickname. At boot, masks removes the account’s second factors and signs it out everywhere. It records both in the activity, and prints a link that sets a new password once. Unset it after use, because masks does this again on every boot. |
MASKS_SETUP_TOKEN |
none | Replaces the setup token that masks generates for each tenant. One value applies to every tenant. Without it, each tenant gets its own token, printed in the server’s logs. The first-run screen asks for the token before it creates a tenant’s first account. Outside development, it must be at least 24 characters long. The dev stack sets it to masks-dev. |
When both MASKS_TENANTS and MASKS_TENANT are unset, masks declares tenants dynamically. See
declaring tenants for how Single, Multi, and Dynamic
differ.
Sign-in policy
Section titled “Sign-in policy”Most of these pin a setting. A pinned setting applies to every tenant. A tenant’s managers cannot
choose it, and the manage API refuses to change it. MASKS_DYNAMIC_CLIENT_SCOPES is the one
variable here that does not pin anything.
| Variable | Default | |
|---|---|---|
MASKS_NAMED_BY |
per tenant, either until a manager changes it |
What an account signs in with: nickname, email, or either. Any other value stops the server from booting. |
MASKS_DYNAMIC_REGISTRATION |
per tenant, bounded when a ceiling is set, otherwise anything |
Whether clients may register themselves. off turns it off. anything allows any scope that a manager does not have to grant. bounded allows only the scopes in the ceiling. Any other value stops the server from booting. |
MASKS_DYNAMIC_CLIENT_SCOPES |
openid, profile, email, offline_access, identities, organization, and groups |
The ceiling, which is the set of scopes a client that registered itself may ask for. Separate them with spaces or commas. A tenant’s own ceiling wins over this one. If you set this without MASKS_DYNAMIC_REGISTRATION, a tenant with no setting of its own becomes bounded. |
MASKS_BROWSERS_ONLY |
per tenant | true refuses sign-in from any user agent that is not a web browser. false allows them. |
MASKS_BLOCKED_AGENTS |
per tenant | User agents to refuse, separated by commas or new lines. An entry matches any user agent that contains it. Case does not matter. |
Rate limits
Section titled “Rate limits”Every limit is a named budget: a count of requests within a fixed window, kept for each tenant. A
request over the budget gets the HTTP status 429 (Too Many Requests), and masks records one
limit.reached event for that budget, address, and window.
Set a budget with its variable, or under limits: in the file MASKS_CONFIG names, by the limit’s
name. The variable wins when both are set. The window does not change. This table is generated from
the budgets masks keeps, so it lists every one.
| Variable | Limit | Default | Counts |
|---|---|---|---|
MASKS_ATTEMPT_LIMIT |
attempt |
10 in 3 minutes | Sign-in attempts from one IP address. Includes sign-in through a provider, failed LDAP binds, and app passwords. |
MASKS_ACCOUNT_ATTEMPT_LIMIT |
account_attempt |
5 in 3 minutes | Sign-in attempts against one account, from any IP address. Includes failed LDAP binds and app passwords. Also how often a signed-in account changes its password, email address, or phone number, adds an authenticator app, or approves a sign-in on another device. |
MASKS_RECOVERY_LIMIT |
recovery |
5 in 15 minutes | Codes and links sent by email or text message. Counted by IP address during sign-in, and by account for every address or phone number a code goes to, including a phone added or changed during sign-in. |
MASKS_REGISTRATION_LIMIT |
registration |
10 in 10 minutes | Dynamic client registrations from one IP address, and new client metadata documents. |
MASKS_DEVICE_CODE_LIMIT |
device_code |
30 in 3 minutes | Device user codes entered from one IP address. |
MASKS_CLAIM_LIMIT |
claim |
3 in 1 hour | Tenants claimed from one IP address, when a subdomain template claims a tenant on its first visit. Counted across the whole server. |
MASKS_CLAIM_CEILING |
claim_ceiling |
30 in 1 hour | Tenants claimed from all IP addresses together, under the same template. Counted across the whole server. |
MASKS_TOKEN_LIMIT |
token |
60 in 1 minute | Token requests from one IP address. |
MASKS_PUSHED_AUTHORIZATION_LIMIT |
pushed_authorization |
60 in 1 minute | Pushed authorization requests from one IP address. |
MASKS_DEVICE_AUTHORIZATION_LIMIT |
device_authorization |
60 in 1 minute | Device authorization requests from one IP address. |
MASKS_INTROSPECTION_LIMIT |
introspection |
120 in 1 minute | Token introspections from one IP address. |
MASKS_REVOCATION_LIMIT |
revocation |
120 in 1 minute | Token revocations from one IP address. |
MASKS_SAML_LIMIT |
saml |
60 in 1 minute | SAML sign-in and logout requests from one IP address. |
MASKS_FORWARD_AUTH_LIMIT |
forward_auth |
30 in 1 minute | Forward auth sign-ins started or finished from one IP address. |
MASKS_ENROLLMENT_LIMIT |
enrollment |
30 in 1 minute | Enrollment tokens redeemed from one IP address. |
MASKS_APP_ENROLLMENT_LIMIT |
app_enrollment |
60 in 1 hour | Enrollment tokens one app mints. |
MASKS_INVITATION_LIMIT |
invitation |
30 in 1 minute | Organization invitations one account sends or sends again. |
MASKS_EXPORT_LIMIT |
export |
5 in 1 hour | Account exports one account asks for. |
MASKS_ACCESS_REQUEST_LIMIT |
access_request |
1 in 1 hour | Times one account asks for access to one app. |
MASKS_SIGNAL_LIMIT |
signal |
600 in 1 minute | Security events received from one IP address. |
MASKS_SCIM_LIMIT |
scim |
600 in 1 minute | SCIM provisioning requests from one IP address. |
masks sends mail through SMTP (Simple Mail Transfer Protocol), the standard way to hand mail to a mail server.
Without MASKS_SMTP_ADDRESS, the server sends no mail of its own. A tenant then needs its own mail
service to send invitations, codes, and password resets. When a tenant has a mail service, masks
uses it instead of these settings.
| Variable | Default | |
|---|---|---|
MASKS_MAIL_FROM |
none | The From address, such as masks <auth@example.com>. In production, it requires MASKS_SMTP_ADDRESS. |
MASKS_SMTP_ADDRESS |
none | The SMTP server’s hostname. Setting it turns on SMTP delivery. |
MASKS_SMTP_PORT |
587 |
The SMTP server’s port. |
MASKS_SMTP_TLS |
true on port 465, otherwise false |
true connects over TLS (Transport Layer Security, the encryption HTTPS uses). false connects without encryption and then switches to it with STARTTLS. masks checks the server’s certificate in both cases. |
MASKS_SMTP_USERNAME |
none | |
MASKS_SMTP_PASSWORD |
none | |
MASKS_SMTP_AUTHENTICATION |
plain |
plain, login, or cram_md5. |
MASKS_SMTP_DOMAIN |
none | The domain masks sends in the HELO greeting. |
Database
Section titled “Database”masks uses three PostgreSQL databases: the primary database, a cache, and a job queue.
It connects as two database roles (database users):
- One role owns the schema and runs migrations.
- The other role serves requests. It has only the table access that
bin/rails masks:grantsgives it.
Tenants are kept apart by row-level security, a PostgreSQL feature that limits which rows a role can see. A superuser skips row-level security, and a table’s owner can turn it off. For that reason, the production server refuses to serve requests as a role that is either one. See the database roles.
| Variable | Default | |
|---|---|---|
POSTGRES_HOST |
127.0.0.1 |
When it is unset, the container image runs its own PostgreSQL inside the container. See one container. |
POSTGRES_PORT |
5432 in production, 5435 otherwise |
Development and test use the port the dev stack publishes by default. |
POSTGRES_USER |
masks |
The role that serves requests. |
POSTGRES_PASSWORD |
masks |
Derived from the master key when masks creates the roles. |
MASKS_MIGRATION_USER |
none | The role that owns the schema. Before it starts the server, the container image’s entrypoint runs db:prepare and masks:grants as this role. The entrypoint does not start without it. It is masks_owner when masks creates the roles. |
MASKS_MIGRATION_PASSWORD |
none | The password for MASKS_MIGRATION_USER. Derived from the master key when masks creates the roles. |
POSTGRES_ADMIN_USER |
postgres |
A role that can create roles on your PostgreSQL server. With POSTGRES_ADMIN_PASSWORD, the entrypoint creates the two roles masks connects as, and sets their passwords, on every boot. |
POSTGRES_ADMIN_PASSWORD |
none | The password for POSTGRES_ADMIN_USER. Leave it unset to create the roles yourself. |
MASKS_SERVING_USER |
none | The role that bin/rails masks:grants gives table access to. The entrypoint sets it to POSTGRES_USER. |
POSTGRES_DATABASE |
masks_production |
The primary database’s name in production. The cache and queue databases add _cache and _queue to it. Development and test use fixed names. |
Processes
Section titled “Processes”The image runs the Puma web server in front of Rails, on PORT. See
self-hosting.
| Variable | Default | |
|---|---|---|
MASKS_JOBS_IN_WEB_SERVER |
true |
true runs background jobs inside the web server, so one container does both. false leaves jobs to a separate bin/jobs process. |
JOB_CONCURRENCY |
1 |
How many worker processes run background jobs. Each one runs 3 threads. |
MASKS_WORKER_SILENCE |
300 |
Seconds a worker may go without reporting before /up answers down. 0 turns the check off, for a server whose jobs run elsewhere. See health checks. |
MASKS_QUEUE_WAIT |
600 |
Seconds a background job may wait to start before /up answers down. 0 turns the check off. |
MASKS_FINISHED_JOB_RETENTION |
604800 (7 days) |
How long a finished background job stays in the queue database before the daily prune removes it. In seconds. |
MASKS_FAILED_JOB_RETENTION |
2592000 (30 days) |
How long a failed background job stays in the queue database before the daily prune removes it. In seconds. |
RAILS_MAX_THREADS |
3 |
Puma threads in each process. It also sets the size of each database connection pool. When it is unset, each pool holds 5 connections. |
PORT |
3000 |
The port Puma listens on. |
PIDFILE |
none | The file where Puma writes its process ID. |
MASKS_RELEASE_CHECK |
false |
true reads the list of releases from GitHub once a day, and the overview says when a newer version is out. The request carries this server’s version and nothing else. See the health panel. |
The web server reads these to serve LDAP (Lightweight Directory Access Protocol), a protocol some apps use to look up accounts and check passwords. See LDAP.
| Variable | Default | |
|---|---|---|
MASKS_LDAP_PORT |
3389 |
The port the web server serves LDAP on. With a certificate, or with MASKS_LDAP_PLAINTEXT, it listens on every network address. Otherwise it listens on 127.0.0.1 alone. |
MASKS_LDAP_CERT |
none | A PEM file (a text file format for certificates and keys) that holds the certificate, followed by any intermediate certificates. With MASKS_LDAP_KEY set too, the server speaks LDAPS, which is LDAP over TLS. |
MASKS_LDAP_KEY |
none | A PEM file that holds the certificate’s private key. Set it together with MASKS_LDAP_CERT. |
MASKS_LDAP_PLAINTEXT |
false |
true serves plain LDAP on every network address without a certificate, so passwords cross the network as they were typed. Set it only on a private network that you trust. |
| Variable | Default | |
|---|---|---|
RAILS_ENV |
production in the image |
production, development, or test. |
RAILS_LOG_LEVEL |
info |
debug, info, warn, error, or fatal. Production only. |
RAILS_ASSUME_SSL |
true |
Treats every request as HTTPS, except a request to localhost, a .localhost name, 127.0.0.1, or [::1]. Use it when a proxy in front of masks handles TLS. Production only. |
RAILS_FORCE_SSL |
true |
Redirects HTTP to HTTPS and sends the Strict-Transport-Security header. It skips the same local names as RAILS_ASSUME_SSL. Production only. |
MASKS_TRUSTED_PROXIES |
none | The addresses or address ranges of the proxies in front of masks, separated by commas. masks adds them to the private ranges Rails already trusts. |
SECRET_KEY_BASE_DUMMY |
unset | Boots with a throwaway secret and skips the production checks above. Use it for build steps only. A server running with it set is not secure. |
A proxy passes on the visitor’s IP address in headers. masks reads X-Forwarded-For,
X-Forwarded-Host, Client-IP, and Forwarded only on a request from a trusted proxy. It drops
these headers from every other request, so a visitor cannot claim a false address. Rate limits and
risk checks use the address that results.
Set MASKS_TRUSTED_PROXIES when a proxy on a public address, such as a CDN (content delivery
network), forwards requests to masks. If you leave it unset, every visitor appears to come from
that proxy’s address, and they all share one set of rate limits.
masks notices both mistakes. When forwarded headers arrive from an address it does not trust, or a
trusted proxy forwards plain HTTP without redirecting to HTTPS, masks writes a line that starts with
proxy: to the log and the Reverse proxy check on the health panel
names the address. An untrusted visitor’s forwarded headers, the scheme among them, are ignored.
Outbound calls
Section titled “Outbound calls”masks refuses to call an address on a private, loopback, or reserved network. This applies when it:
- fetches a client’s keys, logo, sector identifier, metadata document, or resource metadata
- calls a provider or a text message service
- delivers a back-channel logout, a security event, or an event stream
| Variable | Default | |
|---|---|---|
MASKS_OUTBOUND_ALLOWED |
none | Address ranges masks may call anyway, separated by commas. For example, 100.64.0.0/10 allows apps on a private network. |
Themes
Section titled “Themes”| Variable | Default | |
|---|---|---|
MASKS_THEMES_PATH |
/rails/themes |
The folder of theme stylesheets. masks reads it at boot. See themes. |
| Variable | Default | |
|---|---|---|
MASKS_DOCS_URL |
https://masks.pages.dev |
The documentation site that the first-run screens and SCIM’s /ServiceProviderConfig link to. |
Masks::Rails and Masks::Client read no environment variables. Masks::Rails takes its settings
in an initializer, a Ruby file your app runs when it starts. The initializer that
bin/rails generate masks:install writes reads one variable:
| Variable | Default | |
|---|---|---|
MASKS_ISSUER |
https://auth.example.com |
The issuer, which is the masks address your app signs people in through, such as https://demo.auth.example.com. |
The initializer is your code, so you can rename this variable or remove it. The handshake writes the
client’s ID and secret to config/masks.json. See Masks::Rails.
JavaScript
Section titled “JavaScript”@masks/server reads MASKS_ISSUER, MASKS_RESOURCE, MASKS_SECRET, MASKS_CLIENT_ID, and
MASKS_CLIENT_SECRET when you do not pass the matching option. Its Auth.js provider also reads
AUTH_MASKS_ISSUER, AUTH_MASKS_ID, AUTH_MASKS_SECRET, and AUTH_URL. See
@masks/server and Auth.js.
@masks/client runs in the browser and reads no environment variables.
Python and Go
Section titled “Python and Go”The Python and Go SDKs read no environment variables. You pass them the issuer and the client’s credentials in code. See Python apps and Go apps.
Development
Section titled “Development”The dev stack
Section titled “The dev stack”| Variable | Default | |
|---|---|---|
MASKS_PORT |
12345 |
The host port of the dev server. |
MASKS_DOCS_PORT |
12346 |
The host port of the docs site. |
MASKS_VITE_PORT |
3036 |
The host port of the Vite dev server. |
MASKS_IMAGE_PORT |
5556 |
The host port of the production image. The image Compose profile builds and runs it. |
MASKS_FIRST_SIGN_IN_PORT |
5557 |
The host port of the throwaway stack that ./dev first-sign-in times. |
MASKS_FIRST_SIGN_IN_BUDGET |
120 |
The seconds ./dev first-sign-in allows from a fresh image to a signed-in account before it fails. |
MASKS_FIRST_SIGN_IN_TOKEN |
a fixed value | The setup token ./dev first-sign-in gives its throwaway stack. |
MASKS_LIVE_PORT |
5558 |
The host port of the throwaway stack that ./dev live runs every SDK against. |
MASKS_LIVE_TOKEN |
a fixed value | The setup token ./dev live gives its throwaway stack. |
MASKS_LIVE_BIND |
127.0.0.1, or 0.0.0.0 when CI is set |
The address the live apps listen on. On Linux, masks in its container reaches the host through the bridge gateway, so the apps bind every interface there. |
GITHUB_STEP_SUMMARY |
none | Set by GitHub Actions. When present, ./dev first-sign-in, ./dev live, the conformance summary, and the readability report append their tables to the file it names. |
CHECK_LINKS |
unset | When set, the docs build checks every internal link and fails on a broken one. The Docs workflow sets it. |
MASKS_POSTGRES_PORT |
5435 |
The host port of PostgreSQL. |
MASKS_HOST_SUFFIX |
masks.localhost |
The domain whose subdomains the dev server answers. |
PG_BIN_PATH |
none | A folder put first on PATH when masks writes db/structure.sql. Use it to pick a pg_dump that matches the server’s PostgreSQL version. |
DEV_ALLOWED_HOSTS |
none | Hosts the Vite and Astro dev servers answer, separated by commas. Compose sets it. |
DEV_CLIENT_PORT |
none | The port the browser uses to reach the Vite or Astro dev server, so pages reload when files change. Compose sets it. |
VITE_RUBY_HOST |
localhost |
Where Rails finds the Vite dev server. vite_ruby reads it, and Compose sets it. |
VITE_RUBY_SKIP_PROXY |
false |
vite_ruby reads it, and Compose sets it. |
DOCS_SITE |
https://masks.pages.dev |
The docs site’s published address, used for canonical links and the sitemap. The docs workflow sets it for preview deploys. |
| Variable | Default | |
|---|---|---|
MASKS_SERVER_ROOT |
/rails |
Where the provider suite finds the Server-mode app’s built test assets. The suite uses them for the test Engine-mode app it boots. |
TEST_ENV_NUMBER |
none | Added to the test database names, such as masks_test2. A second test run then uses its own database. |
CI |
unset | Loads the whole app up front in tests, as production does. It also makes ./dev test use compose.test.ci.yml. |
RUBOCOP_FORMAT |
progress |
The RuboCop output format for ./dev fmt --check. |
SUITE_REF |
release-v5.2.4 |
The git tag of the OpenID conformance suite that ./dev conformance checks out. |
SUITE_REPO |
the OpenID Foundation’s repository | Where ./dev conformance clones the suite from. |
SUITE_PORT |
8443 |
The port the conformance suite listens on. |
OWNER |
owner |
The nickname of the account the conformance test plans sign in as. |
OWNER_PASSWORD |
password |
The password for OWNER. |