AuthScape

Docs

Environment Variables

Configure AuthScape using environment variables.

Environment variables provide a secure way to configure AuthScape, especially in containerized and cloud environments.

Quick Setup Script

We provide an interactive script to help configure environment variables. Important: Download and review the script before running.

Windows (PowerShell)

Step 1: Download the script

powershell
Invoke-WebRequest -Uri "https://docs.authscape.com/scripts/setup-env.ps1" -OutFile "setup-env.ps1"

Step 2: Review and edit (optional)

Open setup-env.ps1 in your text editor to review what it does. You can also pre-fill values by editing the script directly instead of entering them interactively.

powershell
# Open in Notepad
notepad setup-env.ps1
# Or open in VS Code
code setup-env.ps1

Step 3: Run the script

powershell
.\setup-env.ps1

The script will interactively prompt you for:

  • Database connection details
  • API and client URLs
  • Stripe keys (optional)
  • SendGrid email configuration (optional)
  • Azure Blob Storage (optional)
  • Lucene search / Marketplace (optional)
  • AI services (optional)

Press ENTER to skip any field you don't want to configure.

Linux/Mac (Bash)

Step 1: Download the script

bash
curl -O https://docs.authscape.com/scripts/setup-env.sh

Step 2: Review and edit (optional)

Open setup-env.sh in your text editor to review what it does. You can also pre-fill values by editing the script.

bash
# Open in nano
nano setup-env.sh
# Or open in vim
vim setup-env.sh
# Or open in VS Code
code setup-env.sh

Step 3: Make executable and run

bash
chmod +x setup-env.sh
./setup-env.sh

Step 4: Apply changes

bash
source ~/.bashrc # or ~/.zshrc depending on your shell

Cleanup Script

To remove all AuthScape environment variables:

Windows (PowerShell)

powershell
# Download cleanup script
Invoke-WebRequest -Uri "https://docs.authscape.com/scripts/cleanup-env.ps1" -OutFile "cleanup-env.ps1"
# Review it (optional)
notepad cleanup-env.ps1
# Run it
.\cleanup-env.ps1

Linux/Mac (Bash)

bash
# Download cleanup script
curl -O https://docs.authscape.com/scripts/cleanup-env.sh
# Review it (optional)
cat cleanup-env.sh
# Make executable and run
chmod +x cleanup-env.sh
./cleanup-env.sh

Manual Setup

If you prefer to set variables manually:

Setting Environment Variables

Windows

powershell
# Temporary (current session)
$env:ConnectionStrings__DefaultConnection = "Server=localhost;..."
# Permanent (user level)
[Environment]::SetEnvironmentVariable("AppSettings__Stripe__SecretKey", "sk_xxx", "User")

Linux/Mac

bash
# Temporary
export ConnectionStrings__DefaultConnection="Server=localhost;..."
# Permanent (add to ~/.bashrc or ~/.zshrc)
echo 'export AppSettings__Stripe__SecretKey="sk_xxx"' >> ~/.bashrc

Naming Convention

Environment variables use double underscores (__) to represent hierarchy:

appsettings.jsonEnvironment Variable
ConnectionStrings.DefaultConnectionConnectionStrings__DefaultConnection
AppSettings.Stripe.SecretKeyAppSettings__Stripe__SecretKey
Logging.LogLevel.DefaultLogging__LogLevel__Default

Docker Configuration

dockerfile
ENV ConnectionStrings__DefaultConnection="Server=db;Database=AuthScape;..."
ENV AppSettings__BaseUri="https://api.example.com"

Or with docker-compose:

yaml
services:
api:
environment:
- ConnectionStrings__DefaultConnection=Server=db;Database=AuthScape;...
- AppSettings__BaseUri=https://api.example.com

Azure App Service

Set in Configuration > Application settings:

NameValue
ConnectionStrings__DefaultConnectionServer=...
AppSettings__Stripe__SecretKeysk_live_xxx

Loading Priority

Environment variables override appsettings.json:

csharp
var builder = WebApplication.CreateBuilder(args);
// Order of precedence (highest to lowest):
// 1. Command-line arguments
// 2. Environment variables
// 3. User secrets (Development only)
// 4. appsettings.[Environment].json
// 5. appsettings.json

Next Steps

  • Azure Key Vault
  • AWS Secrets Manager