-
Notifications
You must be signed in to change notification settings - Fork 139
Add automatic authentication monitoring for remote workloads with unauthenticated state detection #2421
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
|
@claude please review this PR and put emphasis on security as well |
|
Claude finished @JAORMX's task —— View job Security-Focused Code ReviewI've completed a thorough security review of this PR, focusing on the authentication monitoring implementation. Overall, this is a well-designed and secure implementation with excellent error handling and safety patterns. Below are my findings: ✅ Security Strengths1. Excellent Error Classification (
|
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #2421 +/- ##
==========================================
+ Coverage 55.08% 55.13% +0.05%
==========================================
Files 293 295 +2
Lines 27950 28023 +73
==========================================
+ Hits 15395 15450 +55
- Misses 11150 11167 +17
- Partials 1405 1406 +1 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
eleftherias
left a comment
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.
Looks good!
There is an edge case where if the token is revoked then this logic won't detect it, but that can be a followup issue for a later time.
Thanks Ria, that's a great catch, I tested this case. If the access token is revoked Token() function does not detect it. In that case we may need to check the http client request's response. But I agree we can handle this in follow up issue later. |
6bc2332 to
f59ddac
Compare
Summary
This PR implements automatic authentication monitoring for remote workloads using OAuth2 authentication. The system proactively detects when authentication tokens expire or fail, automatically marking workloads as unauthenticated without requiring client requests.
Changes
New Component:
AuthenticatedTokenSourceoauth2.TokenSourcethat provides:Token()methodWorkloadStatusUnauthenticatedon authentication failuresKey Features
1. Intelligent Error Classification
oauth2.RetrieveErrorwith HTTP status codes 400/401invalid_grant,invalid_client, orinvalid_token2. Background Monitoring
3. Exponential Backoff
4. Lifecycle Management
Runnerlifecycle:Runner.Cleanup()is called (via context cancellation)sync.Oncefor idempotent channel closureIntegration Points
Runner Integration
AuthenticatedTokenSourceis created for remote workloads with authenticationStatusManagerinterfaceStatus Updates
StatusManager.SetWorkloadStatus()withWorkloadStatusUnauthenticatedTechnical Details
Error Detection
Monitoring Flow
Testing
StatusManagermocksBenefits
Example Scenarios
Scenario 1: Refresh Token Expires
invalid_granterrorWorkloadStatusUnauthenticatedScenario 2: Temporary Network Issue