Skip to content

Add comprehensive login page customization options #7374

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

strickvl
Copy link

@strickvl strickvl commented Jun 12, 2025

This PR adds comprehensive customization options for the login page, allowing users to customize all text elements through CLI arguments, environment variables, or config files.

🎯 Key Features

  • Complete login customization - Every text element can be customized
  • Multiple configuration methods - CLI args, environment variables, YAML config
  • Docker-friendly - Perfect for containerized deployments with env vars
  • Corporate branding - Customize titles, messages, and error text
  • Security-first - All user input is HTML-escaped to prevent XSS
  • Backwards compatible - Existing --app-name/--welcome-text unchanged

📋 New CLI Options

--login-title                      # Custom login page title
--login-below                      # Custom text below login title  
--password-placeholder             # Custom password field placeholder
--submit-text                      # Custom submit button text
--login-password-msg               # Custom config file password message
--login-env-password-msg           # Custom env password message
--login-hashed-password-msg        # Custom hashed password message
--login-rate-limit-msg             # Custom rate limiting message
--missing-password-msg             # Custom missing password error
--incorrect-password-msg           # Custom incorrect password error

🐳 Environment Variables

All CLI options have corresponding CS_* environment variables:

CS_LOGIN_TITLE, CS_LOGIN_BELOW, CS_PASSWORD_PLACEHOLDER, CS_SUBMIT_TEXT
CS_LOGIN_PASSWORD_MSG, CS_LOGIN_ENV_PASSWORD_MSG, CS_LOGIN_HASHED_PASSWORD_MSG  
CS_LOGIN_RATE_LIMIT_MSG, CS_MISSING_PASSWORD_MSG, CS_INCORRECT_PASSWORD_MSG

💼 Use Cases

Docker deployment with branding:

docker run -e CS_LOGIN_TITLE="ACME Corp Portal" \
           -e CS_LOGIN_ENV_PASSWORD_MSG="Contact IT for access" \
           -e CS_PASSWORD_PLACEHOLDER="Corporate ID" \
           codercom/code-server:latest

Corporate error messages:

code-server --missing-password-msg="Please enter your employee ID" \
           --incorrect-password-msg="Invalid credentials. Contact support."

🔧 Implementation Details

  • Priority order: CLI args → env vars → config file → i18n defaults
  • HTML escaping: All custom messages are automatically escaped for security
  • Internationalization: Non-customized messages still use locale files
  • Config file support: All options work in YAML config files
  • Testing: Comprehensive unit and integration tests added

🧪 Test Plan

  • CLI argument parsing for all new options
  • Environment variable processing
  • Config file YAML support
  • HTML output correctness (titles, placeholders, buttons)
  • HTML escaping security (XSS prevention)
  • Error message customization
  • Backwards compatibility with existing options
  • Internationalization preservation
  • Priority order (CLI > env > config > defaults)

📚 Documentation

  • Updated docs/install.md with Docker customization examples
  • Enhanced docs/FAQ.md with login customization section
  • Added comprehensive docs/customization.md guide
  • Updated main docs/README.md with link to customization guide

This enables powerful branding and customization for enterprise deployments while maintaining full backwards compatibility.

Add CLI arguments and environment variables to customize all login page elements:

- Login title, subtitle, and welcome text
- Password field placeholder and submit button text
- Password instruction messages (config file, env var, hashed)
- Error messages (rate limit, missing/incorrect password)

New CLI options:
  --login-title, --login-below, --password-placeholder, --submit-text
  --login-password-msg, --login-env-password-msg, --login-hashed-password-msg
  --login-rate-limit-msg, --missing-password-msg, --incorrect-password-msg

New environment variables:
  CS_LOGIN_TITLE, CS_LOGIN_BELOW, CS_PASSWORD_PLACEHOLDER, CS_SUBMIT_TEXT
  CS_LOGIN_PASSWORD_MSG, CS_LOGIN_ENV_PASSWORD_MSG, CS_LOGIN_HASHED_PASSWORD_MSG
  CS_LOGIN_RATE_LIMIT_MSG, CS_MISSING_PASSWORD_MSG, CS_INCORRECT_PASSWORD_MSG

Features:
- Full backwards compatibility with existing --app-name/--welcome-text
- HTML escaping for security (prevents XSS)
- Config file support (YAML)
- Priority: CLI args > env vars > config file > defaults
- Internationalization preserved for non-customized messages

Perfect for Docker deployments and corporate branding.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <noreply@anthropic.com>
@strickvl strickvl requested a review from a team as a code owner June 12, 2025 17:19
@code-asher
Copy link
Member

code-asher commented Jun 13, 2025

Thank you for the contribution!

Thinking out loud, my first impression is that the flags are not scaling well. Since we have this concept of language files that we can use for strings in the app, I wonder if we can re-use this for user-provided strings as well? Maybe we have a flag that accepts a json file (or accepts raw json itself) and then we can pass that to the i18n library (merged with the default language file).

Then, all strings, including future ones, will automatically be available for configuration. What do you think?

We could then also deprecate --welcome-msg and --app-name.

@strickvl
Copy link
Author

Sounds good. I'll work on that change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants