Skip to content
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

Agent: add new secrets capability to implement secret storage #5348

Merged
merged 1 commit into from
Aug 27, 2024

Conversation

olafurpg
Copy link
Member

@olafurpg olafurpg commented Aug 27, 2024

Previously, the agent only supported stateless secret storage, where the agent server stored secrets in a temporary hashmap that was lost whenever the agent started. Now, clients can optionally declare that they're able to store secrets using the secrets: 'client-managed' capability. With this new capability, client can
store/retrieve/delete/change secrets using the new JSON-RPC methods:

  • secrets/get
  • secrets/store
  • secrets/delete
  • secrets/didChange

Here's the PR moving to client-managed secrets for the Eclipse plugin, which allowed us to delete 600 lines of native UI code 😮 sourcegraph/eclipse#54

Test plan

This PR changes TestClient to use client-managed secrets, so we're stressing this new code path in all the integration tests by default.

Changelog

@olafurpg olafurpg requested review from a team August 27, 2024 14:25
Previously, the agent only supported stateless secret storage, where
the agent server stored secrets in a temporary hashmap that was lost
whenever the agent started. Now, clients can optionally declare that
they're able to store secrets using the `secrets: 'client-managed'`
capability. With this new capability, client can
store/retrieve/delete/change secrets using the new JSON-RPC methods:

* `secrets/get`
* `secrets/store`
* `secrets/delete`
* `secrets/didChange`
@olafurpg olafurpg force-pushed the olafurpg-cody-3509-use-webview-for-authentication-2 branch from 077aaf0 to 59f3458 Compare August 27, 2024 14:43
@olafurpg olafurpg requested a review from jamesmcnamara August 27, 2024 15:02
Copy link
Contributor

@abeatrix abeatrix left a comment

Choose a reason for hiding this comment

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

Lgtm this would be super helpful with the authentication capabilities!

Copy link
Contributor

@jamesmcnamara jamesmcnamara left a comment

Choose a reason for hiding this comment

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

Nice! Agent code is finally starting to look straightforward to me.

@olafurpg olafurpg merged commit d5cfa46 into main Aug 27, 2024
21 checks passed
@olafurpg olafurpg deleted the olafurpg-cody-3509-use-webview-for-authentication-2 branch August 27, 2024 18:56
abeatrix added a commit that referenced this pull request Sep 4, 2024
…ctions (#5325)

Allows agent to set up HTTP server to listen for authentication
redirections when agent capabilities for authentication are enabled.

TODO: 
- [x] authentication url handler
- [x] agent capability configuration 
- [x] work with secret storage (added by
#5348)

Follow-ups:
- we should close the opened browser to refocus the webview if possible.

## Test plan

<!-- Required. See
https://docs-legacy.sourcegraph.com/dev/background-information/testing_principles.
-->

Example of this feature working in Visual Studio:


https://github.com/user-attachments/assets/d21c8c2f-2667-426a-9c4d-991b7645d2e5

Updated onboarding view for non VS Code editors to support login with
browser for enterprise:


![image](https://github.com/user-attachments/assets/19a234a7-83a0-4d52-b918-b1680fa10e72)

## Changelog

<!-- OPTIONAL; info at
https://www.notion.so/sourcegraph/Writing-a-changelog-entry-dd997f411d524caabf0d8d38a24a878c
-->
abeatrix added a commit to sourcegraph/cody-vs that referenced this pull request Sep 6, 2024
CLOSE #72
https://linear.app/sourcegraph/issue/CODY-3619/implement-ivscredentialstorageservice-interface-for-storing-secrets
https://linear.app/sourcegraph/issue/CODY-3618/agent-api-for-secret-storage-capability
https://linear.app/sourcegraph/issue/CODY-3617/implement-agent-requests-for-secret-storage-capability

Try logout and then log back into Cody to confirm you can now use token
redirect and secret storage via Agent:


![image](https://github.com/user-attachments/assets/cf7c1838-11a5-44d0-b655-eeb639259abe)

This PR enables client capability for authentication (added in
sourcegraph/cody#5325) and secrets (added in
sourcegraph/cody#5348) that allows users to use
the native webview for authentication in Cody for Visual Studio.

The protocols for secret storage operations have also been implemented
and the secrets will be stored in
[IVsCredentialStorageService](https://learn.microsoft.com/en-us/dotnet/api/microsoft.visualstudio.shell.connected.credentialstorage?view=visualstudiosdk-2017).

Demo:


https://github.com/user-attachments/assets/d21c8c2f-2667-426a-9c4d-991b7645d2e5

---------

Co-authored-by: Piotr Karczmarz <piotr@karczmarz.com>
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.

3 participants