-
Notifications
You must be signed in to change notification settings - Fork 7
Secure handling and validation of protected secrets #150
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
Conversation
- Validate existing client secrets for blueprints; create new secret only if invalid or expired - Decrypt protected secrets before writing to .env/appsettings.json for Python, Node.js, and .NET projects - Refactor FIC creation logic for clarity and idempotency - Lower log level for existing FIC detection to Debug - Add tests to verify correct decryption and writing of secrets for all supported platforms - Improves security, reliability, and test coverage of secret management
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull request overview
This PR enhances secret management security by validating existing client secrets before creating new ones, properly decrypting protected secrets before writing them to configuration files, and refactoring Federated Identity Credential (FIC) creation logic for improved clarity and idempotency.
Key changes:
- Implements client secret validation with retry logic to avoid unnecessary secret regeneration for existing blueprints
- Adds secret decryption calls in ProjectSettingsSyncHelper for Python, Node.js, and .NET projects to ensure plaintext secrets are written to .env and appsettings.json files
- Refactors FIC creation logic to use a unified code path for both new and existing blueprints, simplifying the implementation
- Adds comprehensive test coverage for protected and unprotected secret handling across platforms
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| ProjectSettingsSyncHelperTests.cs | Adds six new test methods verifying correct decryption and writing of protected/unprotected secrets for Python, Node.js, and .NET platforms |
| FederatedCredentialService.cs | Changes log level from Information to Debug for existing FIC detection to reduce log noise |
| ProjectSettingsSyncHelper.cs | Adds SecretProtectionHelper.UnprotectSecret calls to decrypt secrets before writing to .env files (Python/Node.js) with logger parameter additions |
| BlueprintSubcommand.cs | Implements ValidateClientSecretAsync method for secret validation, adds conditional secret creation logic, and simplifies FIC creation with unified retry logic |
src/Tests/Microsoft.Agents.A365.DevTools.Cli.Tests/Helpers/ProjectSettingsSyncHelperTests.cs
Show resolved
Hide resolved
src/Microsoft.Agents.A365.DevTools.Cli/Commands/SetupSubcommands/BlueprintSubcommand.cs
Outdated
Show resolved
Hide resolved
src/Microsoft.Agents.A365.DevTools.Cli/Commands/SetupSubcommands/BlueprintSubcommand.cs
Outdated
Show resolved
Hide resolved
Refactored BlueprintSubcommand to decrypt secrets and create HttpClient outside the retry loop, improving efficiency and preventing socket exhaustion. Added a test to ProjectSettingsSyncHelperTests to verify that unprotected client secrets are written as-is to appsettings.json.
Fixes #148