Configuration Overview
AuthScape's configuration system works with multiple providers and priority ordering.
AuthScape provides a flexible, centralized configuration system that supports multiple configuration sources. This allows you to manage settings across development, staging, and production environments with ease.
Configuration Sources
AuthScape loads configuration from multiple sources in a specific priority order. Higher priority sources override lower priority ones.
| Priority | Source | Description |
|---|---|---|
| 1 (Lowest) | authscape.json | Shared base configuration |
| 2 | authscape.{Env}.json | Environment-specific shared config |
| 3 | appsettings.json | Project-specific configuration |
| 4 | appsettings.{Env}.json | Project + environment specific |
| 5 | User Secrets | Local development secrets |
| 6 | Environment Variables | Container/CI deployments |
| 7 (Highest) | Azure Key Vault / AWS | Production secrets |
How It Works
When your application starts, the configuration system:
- Discovers shared config by walking up the directory tree to find
authscape.json - Loads project config from
appsettings.jsonin your project - Applies environment overrides based on
ASPNETCORE_ENVIRONMENT - Loads secrets from User Secrets (development) or cloud providers (production)
- Validates settings at startup (optional)
Basic Usage
In your Program.cs, add the AuthScape configuration:
csharp
Host.CreateDefaultBuilder(args).ConfigureAppConfiguration((context, config) =>{config.AddAuthScapeConfiguration(context.HostingEnvironment);}).ConfigureWebHostDefaults(webBuilder =>{webBuilder.UseStartup<Startup>();});
Then in your Startup.cs:
csharp
public void ConfigureServices(IServiceCollection services){services.AddAuthScapeSettings(Configuration, options =>{options.ValidateOnStartup = true;});}
Configuration Options
You can customize the configuration behavior:
csharp
config.AddAuthScapeConfiguration(environment, options =>{// Enable/disable shared configurationoptions.UseSharedConfiguration = true;// Custom path to shared config folderoptions.SharedConfigurationPath = "/path/to/config";// Enable validation at startupoptions.ValidateOnStartup = true;// Enable hot reload of JSON filesoptions.EnableHotReload = true;// Environment variable prefix (default: AUTHSCAPE_)options.EnvironmentVariablePrefix = "AUTHSCAPE_";// Azure Key Vault configurationoptions.AzureKeyVault = new AzureKeyVaultOptions{Enabled = true,VaultUri = "https://your-vault.vault.azure.net/",UseManagedIdentity = true};// AWS Secrets Manager configurationoptions.AwsSecretsManager = new AwsSecretsManagerOptions{Enabled = true,SecretId = "authscape/production",Region = "us-east-1"};});
Next Steps
- appsettings.json - Learn about all available settings
- Shared Config - Set up shared configuration
- Environment Variables - Use environment variables
- Azure Key Vault - Secure secrets in Azure