Repository navigation
Closed
Labels
*out-of-scopePosted issue is not in scope of VS Codeapiunder-discussionIssue is under discussion for relevance, priority, approach
Description
We will offer extension API around keytar such that extensions can use the host OS secret store. Current proposal is:
/**
* Namespace for handling credentials.
*/
export namespace credentials {
/**
* Read a previously stored secret from the credential store.
*
* @param service The service of the credential.
* @param account The account of the credential.
* @return A promise for the secret of the credential.
*/
export function readSecret(service: string, account: string): Thenable<string | undefined>;
/**
* Write a secret to the credential store.
*
* @param service The service of the credential.
* @param account The account of the credential.
* @param secret The secret of the credential to write to the credential store.
* @return A promise indicating completion of the operation.
*/
export function writeSecret(service: string, account: string, secret: string): Thenable<void>;
/**
* Delete a previously stored secret from the credential store.
*
* @param service The service of the credential.
* @param account The account of the credential.
* @return A promise resolving to true if there was a secret for that service and account.
*/
export function deleteSecret(service: string, account: string): Thenable<boolean>;
}Reacted by Markus Wolf, Julien Roncaglia, Jens Hausdorf, Damian and Yukai Huang
Metadata
Metadata
Labels
*out-of-scopePosted issue is not in scope of VS Codeapiunder-discussionIssue is under discussion for relevance, priority, approach
Activity
jrieken commentedon Jul 20, 2017
To me this already looks proper, I wonder if we should create a new namespace or not. Until now we have been adding them very conservatively, my first instinct would be to have these functions in
envwhich also host ofter platform'ish things. Another idea would beExtensionContexttho it scopes things to this extension and I believe the secrets-store is shared for all, right?chrmarti commentedon Jul 20, 2017
Yes, it is shared by all extensions. That is given by our decision to use the OS key chain for implementation. No strong opinion on the namespace. I think it should have its own, like
env.credentials.*.jrieken commentedon Jul 21, 2017
Why do you think so?
jrieken commentedon Jul 21, 2017
Concern raised during the standup is that now all extensions can read/write secrets on behalf of VS Code. We should consider making this API more explicit such that the editor can prompt (at least once) per extension. Something like a
getSecretsStore-function that returns an object to read/write. During that function call we can ask the user if that particular extension is allowed to access secrets, e.gWith such a flow we would be on the save side, similar to browsers that must first get permissions from the OS to use your geo-locations, and then ask per website that wants to use your geo-locations
chrmarti commentedon Jul 21, 2017
On the namespace: Since its already 3 functions it is nicer to put them in context of a name 'credentials'.
env.readSecret()wouldn't speak as much for it self asenv.credentials.readSecret()andenv.readCredentialsSecret()is repetitive when used on all 3 functions.On the confirmation per extension: I'm not convinced the confirmation per extension will add much. From what I have seen on Windows and Linux you unlock the OS key chain once per desktop session, after that all your applications can access it. Only on Mac are you asked per application and credential if that application may access it. An extension can bundle keytar itself and use the unlocked key chains on Windows and Linux and on Mac the prompt would say 'Code Helper' wants to access some credential which isn't much help either.
Unlike with browser's location and other restricted APIs where a webpage cannot bypass the user's decision, extensions have full access.
/cc Chris Dias (@chrisdias)
jrieken commentedon Jul 24, 2017
What throws me off here that mixed usage of
credentialsandsecret. What is it we are dealing with? Will there be more things in thecredentialsnamespace which isn't a secret?Sure, we are not going for security but for clarity. Accessing credentials is a very touchy topic and while I might trust a certain extension I might not trust another extension. I think it's somehow more polite/fair to our users to tell them what extension is now going off with their secrets.
chrmarti commentedon Jul 24, 2017
In my view the secret is just one part of the credential and it is the secret we want to store, not the service or the account name, these are used to access the secret. The credential is account name and secret.
If we ask the user for each secret and extension, wouldn't that lead the user to think that there is some security involved in that question, not just politeness?
Either way, I'd prefer an API with just a single level of promises. Even if we add the user confirmation, we could still go just with promises on the functions without need for a promise on the namespace.
rmunn commentedon Jul 25, 2017
Let me advance a devil's-advocate argument for not doing this. First, an example, and then I'll get to the argument.
Currently, when I start VS Code in a fresh login session (in Linux) and load a folder connected to a Git repository, I see a popup asking for the passphrase to unlock my SSH private key. That's because VS Code's Git extension has tried to do a
git fetch, which in turn has seen that my Git repo has anoriginremote with an SSH URL ([email protected]:rmunn/my-cool-project). It tries to connect to that SSH URL, which causes OpenSSH to read my.sshfolder and find my private SSH key. That key is protected with a passphrase, so OpenSSH asks thessh-agentprocess (which was automatically started when I logged in) to give it access to that particular private key. Thessh-agentprocess then says, "I don't yet have an unlocked version of that private key in memory, let me prompt the user" and causes a secure prompt to pop up to ask me for my passphrase. Once I type in my passphrase, that password is not stored in memory; instead, thessh-agentprocess simply stores the unlocked private key (for a configurable length of time), using the Linux kernel'smlocksyscall to ensure that that region of memory is never written to a swapfile (if it was ever written to disk, an attacker who stole my laptop could theoretically get my unlocked private key out of the swapfile, and do Evil Things with it).That's a lot of complexity, but it Just Works™. And the argument is this: if VS Code adds an interface to keytar (or any other credential-management service), are extensions going to start relying on it? Will the Git extension end up not being able to use the system's SSH agent for unlocking passphrase-protected private keys, because its developers didn't think about the existence of other systems besides keytar? In the case of the Git extension specifically, the answer is almost certainly no, because Git access over SSH is a long-established method and plenty of people rely on it, and there would be no good reason for removing that feature (which works perfectly well) from the code. But in the case of some future extension that does something sensitive (say, managing your OAuth2 client IDs and secrets for you), what if the developers see the existence of the keytar API and take the path of least resistance, when a better solution exists that they didn't see?
This may or may not be a particularly likely scenario, but I think it's one that should be considered. Will adding this API cause people to ignore alternative options?
dtretyakov commentedon Aug 4, 2017
We need a first class support of credentials store in VS Code API to store credentials for web service connection. It will allow extension developers not to bundle packages like keytar and not to implement their own credential stores.
In my vision use case described by Robin Munn (@rmunn) is not representative since it too specific for git. It's up to extension developer to use this API or not. In Git extension it may not be valuable due to existence of Git credentials store, but for VSTS/GitHub and other web service integrations it makes sence.
10 remaining items
mak42 commentedon Sep 4, 2017
Any idea when this feature will be available?
chrmarti commentedon Sep 6, 2017
The discussion on if and how to surface this in the UI is still ongoing.
dtretyakov commentedon Oct 16, 2017
Hi, do you have any new details about discussion of Credentials API?
chrmarti commentedon Oct 16, 2017
Dmitry Tretyakov (@dtretyakov) No, this has stalled.
vscodebot commentedon Dec 1, 2017
This issue is being closed to keep the number of issues in our inbox on a manageable level, we are closing issues that have been on the backlog for a long time but have not gained traction: We look at the number of votes the issue has received and the number of duplicate issues filed. If you disagree and feel that this issue is crucial: We are happy to listen and to reconsider.
If you wonder what we are up to, please see our roadmap and issue reporting guidelines.
Thanks for your understanding and happy coding!