Skip to content

Add CONSOLE_CREDENTIALS_URL env var for service account credentials download #4

@chriswydra

Description

@chriswydra

Problem

When creating a service account and using "Download for import" to get a credentials.json file, the url field in the downloaded JSON contains the value from CONSOLE_MINIO_SERVER (the internal console-to-S3 connection URL).

In many deployments, this internal URL differs from the external S3 endpoint that clients should actually use. For example:

  • Internal: http://minio:9000 (Kubernetes service name)
  • External: https://s3.example.com (public endpoint)

This makes the downloaded credentials.json unusable with tools like mc alias import without manual editing.

Current Behavior

In api/service_accounts_handlers.go, the URL is set via getMinIOServer():

return &models.ServiceAccountCreds{AccessKey: creds.AccessKey, SecretKey: creds.SecretKey, URL: getMinIOServer()}, nil

Which reads from CONSOLE_MINIO_SERVER in api/config.go:

func getMinIOServer() string {
    return strings.TrimSpace(env.Get(ConsoleMinIOServer, "http://localhost:9000"))
}

Proposed Solution

Add a new environment variable CONSOLE_CREDENTIALS_URL that allows administrators to specify the external S3 endpoint URL for downloaded credentials.

In api/consts.go:

ConsoleCredentialsURL = "CONSOLE_CREDENTIALS_URL"

In api/config.go:

func getCredentialsURL() string {
    // Check for explicit credentials endpoint URL (the external S3 URL clients should use)
    if url := env.Get(ConsoleCredentialsURL, ""); url != "" {
        return strings.TrimSpace(url)
    }
    // Fall back to the console's S3 server connection (existing behavior)
    return getMinIOServer()
}

In api/service_accounts_handlers.go:
Replace getMinIOServer() with getCredentialsURL() in the credential return statements.

Why Not Use Backend-Specific Variables?

This approach keeps opens3/console agnostic of the S3 backend. Rather than checking for MinIO-specific variables like MINIO_SERVER_URL, a console-native env var works for any S3-compatible backend:

  • MinIO
  • Ceph/RadosGW
  • AWS S3
  • Any S3-compatible storage

Example Usage

environment:
  - CONSOLE_MINIO_SERVER=http://minio:9000        # Internal connection
  - CONSOLE_CREDENTIALS_URL=https://s3.example.com # External endpoint for credentials

Backward Compatibility

When CONSOLE_CREDENTIALS_URL is not set, behavior remains unchanged (falls back to CONSOLE_MINIO_SERVER).

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions