Where to store a password that you don't want in source control

Viewed 136

While debugging I currently have

#if Debug
   new NetworkCredential("myUsername","myPassword", "myDomain");
#endif

Would a good solution be to store the password in a file and I read the value (only in debug). And then to add that file to the .gitignore?

Production would never read this value as it gets it from an NtlmAuthenticator from RestSharp of the logged in user.

1 Answers

Good practice is to keep it in secret configuration file that you add to your .gitignore

You can do it with file property in appSettings, like:

<appSettings file="..\..\AppSettingsSecrets.config">
    <!-- whatever keys that are kept on source control -->
</appSettings>

and in AppSettingsSecrets.config

<appSettings>   
    <!-- SendGrid-->
    <add key="mailAccount" value="My mail account." />
    <add key="mailPassword" value="My mail password." />
    <!-- Twilio-->
    <add key="TwilioSid" value="My Twilio SID." />
    <add key="TwilioToken" value="My Twilio Token." />
    <add key="TwilioFromPhone" value="+12065551234" />

    <add key="GoogClientID" value="1.apps.googleusercontent.com" />
    <add key="GoogClientSecret" value="My Google client secret." />
</appSettings>
Related