You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Problem:
Extended session duration (90 days) for CodeWhisperer is coming soon, but other scopes on the same SSO connection will not be affected, so there must be handling for "partial" expiration. Partial expiration is relevant when an SSO connection is authorized for both Q/CodeWhisperer and CodeCatalyst.
Solution:
When an AccessDeniedException (ADE) is encountered when making a CodeCatalyst call, it will clear the bearer token. When a bearer token is refreshed, it will call `CodeCatalystClientInternal.verifySession()` before making further calls. If the token was able to refresh, this means that the entire token was not expired, and that specific scopes are expired.
1. If `verifySession` fails due to an ADE, fire an EventEmitter. EventEmitters were used to prevent circular dependencies between `CodeCatalystAuthenticationProvider` and `CodeCatalystClientInternal`. I think it might be better long-term to have the client consume the auth provider, but it would have required a decent amount of refactoring.
2. `CodeCatalystAuthenticationProvider` subscribes to this event, handling the ADE. It will determine if the scope is partially expired, or if all scopes in the connection are expired. It will make a call to CodeWhisperer to determine this.
3. The CodeCatalyst context will be updated, displaying a "Re-Authorize" node in the explorer tree that matches the existing behavior in CodeWhisperer.
4. An information box will display informing the user that CodeCatalyst is expired. If the connection is partially expired, then it will also mention that CodeWhisperer is still useable. This notification will only display at most once per session, and has a "Don't show again" option.
6. On CC activation, check if the connection is shared with CodeWhisperer, and trigger a `verifySession` if it is. This shouldn't impact activation time of users that are not using CC and CW on the same connection.
Additional Changes:
1. Moved `isInDevEnv` from `codecatalyst/utils` to `shared/vscode/env` to prevent circular dependencies.
2. Call `verifySession` during CodeCatalyst activation to detect scope expiration on startup
3. Created `showReauthenticateMessage` function in `utils/messages.ts` for shared functionality between CodeWhisperer and CodeCatalyst
UX Impact:
When the user is not using CodeWhisperer and CodeCatalyst on the same SSO profile, there will not be a UX impact. When the connection is still "valid" (able to refresh the access token), but code catalyst receives an access denied exception while attempting to call `verifySession`, the CC scope is considered expired. Anytime CC scope is expired, it will update the CodeCatalyst explorer to show this. If a user action triggered the CC call, a notification will appear telling the user to authenticate. If the connection was previously expired when starting VSCode, there will not be a notification.
Testing:
1. Added debug commands to expire and un-expire tokens instantly by changing the bearerToken to an invalid token during request signing.
2. Performed testing on a feature-enabled IdC service with the upcoming extended duration changes.
2. Verified that all behavior is expected for just CodeWhisperer, CodeWhisperer & CodeCatalyst, and just CodeCatalyst
0 commit comments