Where to store credentials for VSIX - Visual Studi

2019-03-21 16:06发布

问题:

Context:
I'm writing VSIX Extension for Visual Studio 2017 which needs connection to REST API that requires user authentication. I decide to use VSPackage to provide service for my extension.

To be able to connect and authenticate users I would like to store somewhere user credentials, it could be either username and password or OAuth token - doesn't matter.

Question:
What will be the best place to store credentials information for VSIX?

Requirements:

  • Credentials should not be stored as plain text
  • Should not be stored in text file
  • Should be stored per user
    (We can have more then one windows user, One Windows User = One VS User)
  • Should be available in all running instances of Visual Studio
  • Should work with VS2017 (15.0+) Community, Pro and Enterprise

As for now I've take a look at WritableSettingsStore in UserSettings scope in VS but it was stored in registry by plain text and I would not want to implement my own security on top of that

I've tried also to find more information about IVsCredentialStorageService but it is poorly documented and lack of information about how to use it properly and if it is per user or per system.

回答1:

You can use the Windows Credentials Store, allows you to store in a secure manner per user: https://www.nuget.org/packages/CredentialManagement/