fix(oauth): webhook + oauthblocks in workflow#979
Conversation
There was a problem hiding this comment.
Greptile Summary
This PR addresses two critical OAuth infrastructure issues that prevent server-side workflow execution from working properly with OAuth-enabled tools. The changes implement proper authentication mechanisms for webhook-triggered and scheduled workflow execution scenarios where user session context is not available.
The first change renames the Microsoft identity association file from microsoft-identity-association.json to microsoft-identity-association (without the .json extension). This aligns with Microsoft's OAuth2/OpenID Connect well-known endpoint specifications, which expect this discovery file to be served at the exact path without a file extension. This file contains the Microsoft application ID configuration necessary for OAuth discovery processes.
The second change adds internal JWT authentication support to the OAuth token fetching mechanism in the tools system. When tools execute server-side (detected by typeof window === 'undefined'), the system now generates and includes an internal JWT token in the Authorization header when requesting OAuth tokens. This leverages the existing hybrid authentication system that supports both session-based auth (client-side) and internal JWT auth (server-side). The implementation includes proper error handling to gracefully degrade if internal token generation fails.
These changes integrate with the existing authentication architecture, particularly the /api/auth/oauth/token endpoint that already supports dual authentication modes. The OAuth token endpoint can now properly authenticate server-side requests using short-lived (5-minute) internal JWT tokens signed with the internal secret, while maintaining the existing client-side session-based flow.
PR Description Notes:
- The PR description template is not filled out - missing summary, change type selection, testing details, and checklist completion
- No issue number is referenced despite the template placeholder
Confidence score: 4/5
- This PR addresses legitimate OAuth infrastructure gaps with targeted, well-understood fixes
- Score reflects solid technical implementation but incomplete PR documentation and potential testing gaps
- Pay close attention to the Microsoft identity association file path change and server-side OAuth token flow
2 files reviewed, no comments
* fix(oauth): webhook + oauthblocks in workflow * propagate workflow id * requireWorkflowId for internal can be false
Summary
Need to generate internal token for webhook executions with oauth blocks now. Since credential generation access is secured.
Type of Change
Testing
Tested manually by triggering webhooks with oauth blocks in the workflow.
Checklist