mirror of
https://github.com/oauth2-proxy/oauth2-proxy.git
synced 2026-10-20 09:04:28 +02:00
feat: add --config-test flag for validating configuration (#3338)
* feat: add --config-test flag for validating configuration without starting the proxy Signed-off-by: MayorFaj <mayorfaj@gmail.com> * doc: fix alpha config and add changelog entry for #3338 Signed-off-by: Jan Larwig <jan@larwig.com> --------- Signed-off-by: MayorFaj <mayorfaj@gmail.com> Signed-off-by: Jan Larwig <jan@larwig.com> Co-authored-by: Jan Larwig <jan@larwig.com>
This commit is contained in:
co-authored by
Jan Larwig
parent
fe5c6becec
commit
51ecc50372
@@ -106,6 +106,17 @@ the new config.
|
||||
oauth2-proxy --alpha-config ./path/to/new/config.yaml --config ./path/to/existing/config.cfg
|
||||
```
|
||||
|
||||
### Validating Alpha Configuration
|
||||
|
||||
Use `--config-test` to validate your alpha configuration without starting the proxy:
|
||||
|
||||
```bash
|
||||
oauth2-proxy --config core.cfg --alpha-config alpha.yaml --config-test
|
||||
```
|
||||
|
||||
This is useful for CI/CD pipelines to catch configuration errors before deployment.
|
||||
See the [Configuration Validation](./overview.md#configuration-validation) section for more details.
|
||||
|
||||
### How to use environment variables
|
||||
|
||||
The alpha package supports the use of environment variables in place of yaml values, allowing sensitive data to be pulled from somewhere other than the yaml file.
|
||||
|
||||
@@ -106,6 +106,17 @@ the new config.
|
||||
oauth2-proxy --alpha-config ./path/to/new/config.yaml --config ./path/to/existing/config.cfg
|
||||
```
|
||||
|
||||
### Validating Alpha Configuration
|
||||
|
||||
Use `--config-test` to validate your alpha configuration without starting the proxy:
|
||||
|
||||
```bash
|
||||
oauth2-proxy --config core.cfg --alpha-config alpha.yaml --config-test
|
||||
```
|
||||
|
||||
This is useful for CI/CD pipelines to catch configuration errors before deployment.
|
||||
See the [Configuration Validation](./overview.md#configuration-validation) section for more details.
|
||||
|
||||
### How to use environment variables
|
||||
|
||||
The alpha package supports the use of environment variables in place of yaml values, allowing sensitive data to be pulled from somewhere other than the yaml file.
|
||||
|
||||
@@ -66,11 +66,48 @@ An example [oauth2-proxy.cfg](https://github.com/oauth2-proxy/oauth2-proxy/blob/
|
||||
|
||||
### Command Line Options
|
||||
|
||||
| Flag | Description |
|
||||
| ----------- | -------------------- |
|
||||
| `--config` | path to config file |
|
||||
| `--version` | print version string |
|
||||
| Flag | Description |
|
||||
| ---------------- | ------------------------------------------------------- |
|
||||
| `--config` | path to config file |
|
||||
| `--config-test` | test configuration and exit (for CI/CD validation) |
|
||||
| `--version` | print version string |
|
||||
|
||||
## Configuration Validation
|
||||
|
||||
The `--config-test` flag validates your configuration file without starting the proxy server. This is useful for:
|
||||
- **CI/CD pipelines**: Pre-deployment validation
|
||||
- **Configuration management**: Testing before applying changes
|
||||
- **Debugging**: Verifying syntax and required fields
|
||||
|
||||
### Usage
|
||||
|
||||
```bash
|
||||
# Test legacy config
|
||||
oauth2-proxy --config /etc/oauth2-proxy.cfg --config-test
|
||||
|
||||
# Test alpha config
|
||||
oauth2-proxy --config /etc/core.cfg --alpha-config /etc/alpha.yaml --config-test
|
||||
|
||||
# CI/CD pre-deployment check
|
||||
# Returns with exit code 1 if any validation errors occur
|
||||
oauth2-proxy --config new-config.cfg --config-test
|
||||
```
|
||||
|
||||
### Exit Codes
|
||||
|
||||
- **0**: Configuration is valid ✅
|
||||
- **1**: Configuration is invalid (errors printed to stderr) ❌
|
||||
|
||||
### Validation Coverage
|
||||
|
||||
The `--config-test` flag performs the **same comprehensive validation** as normal startup, including:
|
||||
- Required fields (client ID, client secret, cookie secret, etc.)
|
||||
- Syntax validation (TOML/YAML parsing)
|
||||
- Provider configuration
|
||||
- Upstream server definitions
|
||||
- Session store connectivity (e.g., Redis network checks if configured)
|
||||
|
||||
**Note**: Cannot be combined with `--convert-config-to-alpha`.
|
||||
|
||||
### General Provider Options
|
||||
|
||||
|
||||
Reference in New Issue
Block a user