Skip to content

Background Services Authentication Flow#4

Open
ArturKarbone wants to merge 8 commits intomasterfrom
feature/background-services-auth
Open

Background Services Authentication Flow#4
ArturKarbone wants to merge 8 commits intomasterfrom
feature/background-services-auth

Conversation

@ArturKarbone
Copy link
Copy Markdown
Collaborator

No description provided.

@ArturKarbone ArturKarbone requested a review from Copilot March 29, 2026 06:52
@ArturKarbone ArturKarbone marked this pull request as ready for review March 29, 2026 06:53
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new Poc.BackgroundWorker sample demonstrating machine-to-machine authentication for background services using OAuth2 client-credentials (Keycloak) to call the existing Weather API through YARP.

Changes:

  • Introduces a .NET worker service that acquires client-credentials tokens and periodically calls /weatherforecast via YARP.
  • Adds token acquisition service code (plus an optional cached wrapper) and sample configuration.
  • Adds documentation for background-service authentication and updates solution/launch configuration to include the new sample.

Reviewed changes

Copilot reviewed 12 out of 12 changed files in this pull request and generated 9 comments.

Show a summary per file
File Description
samples/Poc.BackgroundWorker/appsettings.json Adds Keycloak/YARP/worker polling configuration for the new sample.
samples/Poc.BackgroundWorker/appsettings.Development.json Development logging overrides for the new worker.
samples/Poc.BackgroundWorker/Workers/WeatherBackgroundService.cs Implements periodic token acquisition + API call + logging for the worker.
samples/Poc.BackgroundWorker/Services/ClientCredentialsTokenService.cs Implements client-credentials token acquisition against Keycloak token endpoint.
samples/Poc.BackgroundWorker/Services/CachedClientCredentialsTokenService.cs Adds an in-memory caching wrapper for tokens (currently not wired up).
samples/Poc.BackgroundWorker/README.md Usage/architecture/docs for running the background worker sample.
samples/Poc.BackgroundWorker/Program.cs Registers OIDC options, HttpClient, token service, and hosted worker.
samples/Poc.BackgroundWorker/Poc.BackgroundWorker.csproj New worker project file and package references.
samples/Poc.Api/Program.cs Minor whitespace cleanup in OIDC options configuration.
docs/BACKGROUND-SERVICES-AUTHENTICATION.md New guide explaining background-service authentication and token caching.
AppForeach.TokenHandler.slnLaunch Updates launch profile to start API + internal API + YARP + background worker.
AppForeach.TokenHandler.sln Adds new project and docs solution items.

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