Skip to content

opencloud init: support environment variables for all generated secrets #2483

@bernardgut

Description

@bernardgut

Problem

opencloud init generates random passwords for all internal secrets (IDM service passwords, JWT, transfer secrets, etc.) and provides no mechanism to inject pre-defined values via environment variables.

In containerized deployments (Kubernetes, Docker), this means:

  • Every pod restart with an empty config dir generates new random secrets
  • IDM (LDAP) service passwords written during init no longer match what services use at runtime
  • This causes LDAP bind failures and broken authentication after any restart without config volume persistence

Only --admin-password is exposed as a CLI flag. The 12 other secrets have no override mechanism.

Affected secrets

Secret Config field Proposed ENV var
IDM service password idm.service_user_config.password IDM_SVC_PASSWORD
IDM Reva service password idm.service_user_config.reva_password IDM_REVASVC_PASSWORD
IDM IDP service password idm.service_user_config.idp_password IDM_IDPSVC_PASSWORD
Admin password admin_password OC_ADMIN_PASSWORD
JWT secret token_manager.jwt_secret OC_JWT_SECRET
Machine auth API key machine_auth_api_key OC_MACHINE_AUTH_API_KEY
Transfer secret transfer_secret OC_TRANSFER_SECRET
Service account secret service_account.service_account_secret OC_SERVICE_ACCOUNT_SECRET
WOPI secret collaboration.wopi.wopi_src_secret COLLABORATION_WOPI_SECRET
System user API key system_user_api_key SYSTEM_USER_API_KEY
URL signing secret n/a OC_URL_SIGNING_SECRET
Thumbnails transfer secret n/a THUMBNAILS_TRANSFER_SECRET

Proposed fix

Add a helper in opencloud/pkg/init/ that checks for the corresponding environment variable before falling back to random generation:

func secretFromEnvOrRandom(envVar string, length int) (string, error) {
    if v := os.Getenv(envVar); v != "" {
        return v, nil
    }
    return generators.GenerateRandomPassword(length)
}

This is fully backward-compatible: when no ENV var is set, behavior is identical to today.

Use case

Helm charts and container orchestrators can inject stable, pre-defined secrets via Kubernetes Secrets → ENV vars, eliminating the need for config volume persistence and ensuring LDAP credentials remain consistent across restarts.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions