Skip to content

Refactor SetupCommand to use GraphTokenScopeException#36

Merged
sellakumaran merged 1 commit intomainfrom
users/sellak/setupScopeIssue
Nov 20, 2025
Merged

Refactor SetupCommand to use GraphTokenScopeException#36
sellakumaran merged 1 commit intomainfrom
users/sellak/setupScopeIssue

Conversation

@sellakumaran
Copy link
Copy Markdown
Contributor

@sellakumaran sellakumaran commented Nov 20, 2025

  • Added GraphApiService as a dependency in SetupCommand and replaced inline instantiations with dependency injection.
  • Introduced GraphTokenScopeException to handle disallowed high-privilege scopes in Graph tokens.
  • Implemented ValidateGraphToken in A365SetupRunner to enforce least-privilege principles during token validation.
  • Refactored GetTokenFromGraphClient to use Azure.Identity for token retrieval and validation.
  • Added new error code HighPrivilegeScopeDetected to ErrorCodes for better error categorization.
  • Updated Program.cs to inject GraphApiService at runtime.
  • Enhanced unit tests to mock GraphApiService and ensure coverage of new functionality.
  • Removed redundant code and improved exception handling to exclude Agent365Exception from generic catch blocks.
image

- Added `GraphApiService` as a dependency in `SetupCommand`
  and replaced inline instantiations with dependency injection.
- Introduced `GraphTokenScopeException` to handle disallowed
  high-privilege scopes in Graph tokens.
- Implemented `ValidateGraphToken` in `A365SetupRunner` to
  enforce least-privilege principles during token validation.
- Refactored `GetTokenFromGraphClient` to use `Azure.Identity`
  for token retrieval and validation.
- Added new error code `HighPrivilegeScopeDetected` to
  `ErrorCodes` for better error categorization.
- Updated `Program.cs` to inject `GraphApiService` at runtime.
- Enhanced unit tests to mock `GraphApiService` and ensure
  coverage of new functionality.
- Removed redundant code and improved exception handling
  to exclude `Agent365Exception` from generic catch blocks.
- Performed general code cleanup and added licensing
  information to new files.
@sellakumaran sellakumaran requested review from a team as code owners November 20, 2025 19:07
@sellakumaran sellakumaran merged commit 319fadf into main Nov 20, 2025
2 checks passed
@sellakumaran sellakumaran deleted the users/sellak/setupScopeIssue branch December 4, 2025 19:14
sellakumaran added a commit that referenced this pull request Feb 27, 2026
- Added `GraphApiService` as a dependency in `SetupCommand`
  and replaced inline instantiations with dependency injection.
- Introduced `GraphTokenScopeException` to handle disallowed
  high-privilege scopes in Graph tokens.
- Implemented `ValidateGraphToken` in `A365SetupRunner` to
  enforce least-privilege principles during token validation.
- Refactored `GetTokenFromGraphClient` to use `Azure.Identity`
  for token retrieval and validation.
- Added new error code `HighPrivilegeScopeDetected` to
  `ErrorCodes` for better error categorization.
- Updated `Program.cs` to inject `GraphApiService` at runtime.
- Enhanced unit tests to mock `GraphApiService` and ensure
  coverage of new functionality.
- Removed redundant code and improved exception handling
  to exclude `Agent365Exception` from generic catch blocks.
- Performed general code cleanup and added licensing
  information to new files.
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