Skip to content

Configuration

можно. is configured entirely through MOZHNO_* environment variables. All settings have sensible defaults so you only need to set what differs from the standard setup.

Config model: the application reads configuration only from MOZHNO_* environment variables. All have safe defaults — the server starts without any configuration. A full template is in .env.example. The dev profile (SPRING_PROFILES_ACTIVE=dev) is for local development from source only.

How to set variables

Docker Compose — under the service environment section:

yaml
services:
  mozhno:
    image: mozhnodev/mozhno:latest
    environment:
      MOZHNO_JWT_SECRET: ${MOZHNO_JWT_SECRET}   # from .env or host environment
      MOZHNO_DB_URL: jdbc:postgresql://postgres:5432/feature_flags
      MOZHNO_DB_PASSWORD: secret
      MOZHNO_BASE_URL: https://flags.example.com

docker run — via -e flags:

bash
docker run -p 8080:8080 \
  -e MOZHNO_JWT_SECRET=$(openssl rand -base64 32) \
  -e MOZHNO_DB_URL=jdbc:postgresql://db:5432/feature_flags \
  -e MOZHNO_DB_PASSWORD=secret \
  mozhnodev/mozhno:latest

.env file (picked up by Docker Compose automatically):

bash
MOZHNO_JWT_SECRET=your-256-bit-secret
MOZHNO_DB_PASSWORD=secret
MOZHNO_JWT_ACCESS_TOKEN_TTL_MINUTES=30

Running the JAR directly — via process environment variables:

bash
export MOZHNO_JWT_SECRET=$(openssl rand -base64 32)
export MOZHNO_DB_PASSWORD=secret
java -jar mozhno.jar

Core Variables

These are the most commonly configured environment variables:

VariableDefaultDescription
MOZHNO_JWT_SECRET— (optional for dev)Secret key for signing JWTs. Minimum 256 bits (32 bytes). Accepts both plain text (>= 32 characters) and Base64 (>= 32 bytes decoded). If not set, a random key is generated at startup — tokens will be invalidated on restart. Set explicitly for production.
MOZHNO_SERVER_PORT8080HTTP listen port
MOZHNO_BASE_URLhttp://localhost:8080Publicly reachable URL of the server. Used for generating links in emails, webhook payloads, and OAuth redirects. Must include protocol (http/https) and no trailing slash.

Database Variables

VariableDefaultDescription
MOZHNO_DB_URLjdbc:postgresql://localhost:5432/feature_flagsJDBC connection URL
MOZHNO_DB_USERNAMEflags_userDatabase username
MOZHNO_DB_PASSWORDflags_passwordDatabase password
MOZHNO_DB_POOL_MAX_SIZE20Maximum connections in the HikariCP connection pool. Increase for high-traffic deployments.
MOZHNO_DB_POOL_MIN_IDLE5Minimum idle connections kept in the pool
MOZHNO_DB_POOL_CONNECTION_TIMEOUT10000Maximum wait time (ms) for a connection from the pool

JWT & Authentication

VariableDefaultDescription
MOZHNO_JWT_SECRET— (optional for dev)HMAC-SHA256 secret for signing access and refresh tokens. Auto-generated on startup if not set — set explicitly in production so tokens survive restarts
MOZHNO_JWT_ACCESS_TOKEN_TTL_MINUTES15Access token lifetime in minutes
MOZHNO_JWT_REFRESH_TOKEN_TTL_DAYS30Refresh token lifetime in days

можно. uses JWT authentication with refresh token family rotation. When a refresh token is used, both the old access and refresh tokens are invalidated and new ones are issued. If a stolen (already-revoked) token is presented, the entire token family is revoked — locking out the attacker.

Logging

VariableDefaultDescription
LOGGING_LEVEL_ROOTINFORoot log level. Set to DEBUG for troubleshooting.
LOGGING_LEVEL_DEV_MOZHNOINFOLog level for можно. application code

CORS

VariableDefaultDescription
MOZHNO_SECURITY_CORS_ALLOWED_ORIGINS*Comma-separated list of allowed origins for CORS. Set to your frontend origin in production.

Cache & Metrics

VariableDefaultDescription
MOZHNO_CACHE_TYPEcaffeineSpring cache type. caffeine — in-memory (default). For Redis add spring-boot-starter-data-redis and set to redis
MOZHNO_CACHE_TTL_MINUTES5Cache TTL in minutes
MOZHNO_CLIENT_MAX_METRICS_PER_KEY1000Maximum stored metrics entries per client API key

Bootstrap (First Launch)

VariableDefaultDescription
MOZHNO_INIT_EMAIL— (not set — no admin created)Email of the admin user created on first launch (when the DB has no users)
MOZHNO_INIT_PASSWORDPassword for the initial admin user

On first launch with an empty database, the server bootstraps:

  • An admin user — when both MOZHNO_INIT_EMAIL and MOZHNO_INIT_PASSWORD are set, and no users exist yet
  • A default project named «Default Project» — when no projects exist yet

If the variables are not set, the server starts with no users — login will be impossible. Set them or create the admin manually via a direct DB INSERT.

The bootstrap admin is not re-created on subsequent starts — if users already exist in the DB, bootstrap is skipped.

Docker Compose Example

A minimal Docker Compose configuration with all essential variables:

yaml
services:
  postgres:
    image: postgres:15-alpine
    environment:
      POSTGRES_DB: feature_flags
      POSTGRES_USER: flags_user
      POSTGRES_PASSWORD: ${DB_PASSWORD}

  mozhno:
    image: mozhnodev/mozhno:latest
    ports:
      - '8080:8080'
    environment:
      MOZHNO_DB_URL: jdbc:postgresql://postgres:5432/feature_flags
      MOZHNO_DB_USERNAME: flags_user
      MOZHNO_DB_PASSWORD: ${DB_PASSWORD}
      MOZHNO_JWT_SECRET: ${MOZHNO_JWT_SECRET}
      MOZHNO_BASE_URL: https://flags.example.com
      MOZHNO_SERVER_PORT: '8080'
      MOZHNO_JWT_ACCESS_TOKEN_TTL_MINUTES: '15'
      MOZHNO_JWT_REFRESH_TOKEN_TTL_DAYS: '30'
      MOZHNO_DB_POOL_MAX_SIZE: '20'
      MOZHNO_DB_POOL_MIN_IDLE: '5'
      MOZHNO_CACHE_TTL_MINUTES: '5'
      MOZHNO_INIT_EMAIL: ${MOZHNO_INIT_EMAIL:-admin@admin.com}
      MOZHNO_INIT_PASSWORD: ${MOZHNO_INIT_PASSWORD:-admin}

Production Checklist

  1. Generate a strong MOZHNO_JWT_SECRET — use openssl rand -base64 32 (one option; a plain text string of >= 32 characters also works), never use the default or a predictable value.
  2. Set MOZHNO_BASE_URL to your real public URL — incorrect values break OAuth callbacks and webhook delivery.
  3. Restrict MOZHNO_SECURITY_CORS_ALLOWED_ORIGINS to your actual frontend domain.
  4. Use environment-specific secrets — never reuse MOZHNO_JWT_SECRET across staging and production.
  5. Enable PostgreSQL SSL — append ?ssl=true&sslmode=require to the JDBC URL in production.
  6. Set MOZHNO_SERVER_PORT if running behind a reverse proxy on a non-standard port.
  7. Change the admin password — after first login with bootstrap credentials (MOZHNO_INIT_EMAIL / MOZHNO_INIT_PASSWORD), change the password immediately. Never use admin@admin.com / admin in production.

SMTP (Email)

VariableDefaultDescription
MOZHNO_SMTP_HOSTlocalhostSMTP server host
MOZHNO_SMTP_PORT587SMTP server port
MOZHNO_SMTP_USERNAMESMTP username
MOZHNO_SMTP_PASSWORDSMTP password
MOZHNO_MAIL_FROMnoreply@mozhno.devSender email address

More Settings

Additional groups with sensible defaults (no need to change unless tuning):

VariableDefaultDescription
MOZHNO_SECURITY_BCRYPT_STRENGTH12BCrypt hashing cost factor
MOZHNO_SECURITY_MAX_FAILED_LOGIN_ATTEMPTS5Failed logins before account lockout
MOZHNO_SECURITY_LOCKOUT_DURATION_MINUTES15Account lockout duration (minutes)
MOZHNO_AUTH_PASSWORD_RESET_TOKEN_TTL_HOURS1Password reset token lifetime (hours)
MOZHNO_AUTH_PASSWORD_RESET_COOLDOWN_MINUTES5Minimum delay between reset emails (minutes)
MOZHNO_AUTH_INVITE_TOKEN_TTL_DAYS7Invite token lifetime (days)
MOZHNO_AUTH_ACTIVITY_WINDOW_MINUTES5How often a user's activity timestamp is refreshed (minutes)
MOZHNO_WEBHOOK_CONNECT_TIMEOUT_SECONDS10Webhook connect timeout (seconds)
MOZHNO_WEBHOOK_REQUEST_TIMEOUT_SECONDS30Webhook request timeout (seconds)
MOZHNO_WEBHOOK_ASYNC_CORE_POOL_SIZE4Webhook thread pool core size
MOZHNO_WEBHOOK_ASYNC_MAX_POOL_SIZE16Webhook thread pool max size
MOZHNO_WEBHOOK_ASYNC_QUEUE_CAPACITY100Webhook task queue capacity
MOZHNO_FLAGS_MAX_TAGS_PER_FLAG10Max tags per flag
MOZHNO_FLAGS_DEFAULT_PAGE_SIZE50Default page size
MOZHNO_FLAGS_MAX_PAGE_SIZE200Max page size (flag listing)
MOZHNO_FLAGS_ENRICHED_MAX_PAGE_SIZE500Max page size (enriched listing)
MOZHNO_CACHE_MAX_SIZE5000Max entries per cache
MOZHNO_MANAGEMENT_PORT9090Actuator/metrics port
MOZHNO_SWAGGER_ENABLEDtrueEnable Swagger UI
MOZHNO_LOG_LEVEL_ROOTINFORoot log level
MOZHNO_LOG_LEVEL_APPINFOdev.mozhno log level

The full list with defaults is in .env.example.

Next Steps

Released under the BSL 1.1 License.