public override void Load() { // use SFCCAccountManager and then account.demandware.com application password if set var secretPair = SecretsConfigurationProvider.ApplicationPasswordFromKeychain("SFCCAccountManager") ?? SecretsConfigurationProvider.InternetPasswordFromKeychain("account.demandware.com"); if (secretPair != null) { this.Data.Add("Username", secretPair.Username); this.Data.Add("Password", secretPair.Password); } // allow storage of global client credentials in secret story secretPair = SecretsConfigurationProvider.ApplicationPasswordFromKeychain("SFCCAccountManagerClientCredentials"); if (secretPair != null) { this.Data.Add("ClientID", secretPair.Username); this.Data.Add("ClientSecret", secretPair.Password); } }
public override void Load() { base.Load(); string targetProject; if (!string.IsNullOrEmpty(Project)) { targetProject = Project; } else { this.Data.TryGetValue("defaultProject", out targetProject); } if (!string.IsNullOrEmpty(targetProject)) { string targetEnvironment; if (!string.IsNullOrEmpty(Environment)) { targetEnvironment = Environment; } else { this.Data.TryGetValue($"projects:{targetProject}:defaultEnvironment", out targetEnvironment); } if (!string.IsNullOrEmpty(targetEnvironment)) { // attempt to load keys from the target environment if (this.Data.TryGetValue($"projects:{targetProject}:environments:{targetEnvironment}:username", out var username)) { this.Data.Add("Username", username); } if (this.Data.TryGetValue($"projects:{targetProject}:environments:{targetEnvironment}:password", out var password)) { this.Data.Add("Password", password); } if (this.Data.TryGetValue($"projects:{targetProject}:environments:{targetEnvironment}:server", out var server)) { this.Data.Add("Server", server); } if (this.Data.TryGetValue($"projects:{targetProject}:environments:{targetEnvironment}:codeVersion", out var codeVersion)) { this.Data.Add("CodeVersion", codeVersion); } if (this.Data.TryGetValue($"projects:{targetProject}:environments:{targetEnvironment}:clientID", out var clientID)) { this.Data.Add("ClientID", clientID); } if (this.Data.TryGetValue($"projects:{targetProject}:environments:{targetEnvironment}:clientSecret", out var clientSecret)) { this.Data.Add("ClientSecret", clientSecret); } // Support account manager username at top of file if not specified this.Data.TryGetValue("accountManager:username", out var accountManagerUsername); if (string.IsNullOrEmpty(username) && !string.IsNullOrEmpty(accountManagerUsername)) { this.Data.Add("Username", accountManagerUsername); } this.Data.TryGetValue("accountManager:password", out var accountManagerPassword); if (string.IsNullOrEmpty(password) && !string.IsNullOrEmpty(accountManagerPassword)) { this.Data.Add("Password", accountManagerPassword); } // Finally attempt to retrieve information from keychain if no password but username available if (this.Data.ContainsKey("Username") && !this.Data.ContainsKey("Password") && !string.IsNullOrEmpty(server)) { var uname = this.Data["Username"]; // check if we have a password for this exact server and username var secretPair = SecretsConfigurationProvider.InternetPasswordFromKeychain(server, uname); if (secretPair != null) { this.Data.Add("Password", secretPair.Password); } } } } }