public async Task <List <ProviderResourceSuggestion> > EnumerateResourceCandidates(AuthJanitorProviderConfiguration baseConfig) { var azureConfig = baseConfig as AzureAuthJanitorProviderConfiguration; IPagedCollection <IFunctionApp> items; if (!string.IsNullOrEmpty(azureConfig.ResourceGroup)) { items = await(await GetAzureAsync()).AppServices.FunctionApps.ListByResourceGroupAsync(azureConfig.ResourceGroup); } else { items = await(await GetAzureAsync()).AppServices.FunctionApps.ListAsync(); } return((await Task.WhenAll(items.Select(async i => { return (await i.GetAppSettingsAsync()).Select(a => new ProviderResourceSuggestion() { Configuration = new AppSettingConfiguration() { ResourceName = i.Name, ResourceGroup = i.ResourceGroupName, SettingName = a.Key }, Name = $"Functions/AppSetting - {i.ResourceGroupName} - {i.Name} ({a.Key})", ProviderType = this.GetType().AssemblyQualifiedName, ResourceValues = new[] { a.Value?.Value }, AddressableNames = i.EnabledHostNames.ToList() }); }))).SelectMany(f => f).ToList()); }
public async Task <List <ProviderResourceSuggestion> > EnumerateResourceCandidates(AuthJanitorProviderConfiguration baseConfig) { var azureConfig = baseConfig as AzureAuthJanitorProviderConfiguration; IPagedCollection <IStorageAccount> items; if (!string.IsNullOrEmpty(azureConfig.ResourceGroup)) { items = await(await GetAzureAsync()).StorageAccounts.ListByResourceGroupAsync(azureConfig.ResourceGroup); } else { items = await(await GetAzureAsync()).StorageAccounts.ListAsync(); } return(items.Select(i => { return new ProviderResourceSuggestion() { Configuration = new StorageAccountKeyConfiguration() { ResourceGroup = i.ResourceGroupName, ResourceName = i.Name }, Name = $"Storage Account - {i.ResourceGroupName} - {i.Name}", ProviderType = this.GetType().AssemblyQualifiedName, AddressableNames = new List <string>() { i.Name, i.EndPoints?.Primary?.Blob, i.EndPoints?.Primary?.Dfs, i.EndPoints?.Primary?.File, i.EndPoints?.Primary?.Queue, i.EndPoints?.Primary?.Table, i.EndPoints?.Primary?.Web, i.EndPoints?.Secondary?.Blob, i.EndPoints?.Secondary?.Dfs, i.EndPoints?.Secondary?.File, i.EndPoints?.Secondary?.Queue, i.EndPoints?.Secondary?.Table, i.EndPoints?.Secondary?.Web, }.Where(a => !string.IsNullOrEmpty(a)) }; }).ToList()); }
public async Task <List <ProviderResourceSuggestion> > EnumerateResourceCandidates(AuthJanitorProviderConfiguration baseConfig) { var azureConfig = baseConfig as AzureAuthJanitorProviderConfiguration; IPagedCollection <ICosmosDBAccount> items; if (!string.IsNullOrEmpty(azureConfig.ResourceGroup)) { items = await(await GetAzureAsync()).CosmosDBAccounts.ListByResourceGroupAsync(azureConfig.ResourceGroup); } else { items = await(await GetAzureAsync()).CosmosDBAccounts.ListAsync(); } return((await Task.WhenAll(items.Select(async i => new ProviderResourceSuggestion() { Configuration = new CosmosDbKeyConfiguration() { ResourceGroup = i.ResourceGroupName, ResourceName = i.Name, KeyType = CosmosDbKeyConfiguration.CosmosDbKeyKinds.Primary, }, Name = $"CosmosDB - {i.ResourceGroupName} - {i.Name}", ProviderType = this.GetType().AssemblyQualifiedName, AddressableNames = (await i.ListConnectionStringsAsync()).ConnectionStrings.Select(s => s.ConnectionString) }))).ToList()); }
public async Task <List <ProviderResourceSuggestion> > EnumerateResourceCandidates(AuthJanitorProviderConfiguration baseConfig) { var azureConfig = baseConfig as AzureAuthJanitorProviderConfiguration; IPagedCollection <IFunctionApp> items; if (!string.IsNullOrEmpty(azureConfig.ResourceGroup)) { items = await(await GetAzureAsync()).AppServices.FunctionApps.ListByResourceGroupAsync(azureConfig.ResourceGroup); } else { items = await(await GetAzureAsync()).AppServices.FunctionApps.ListAsync(); } return((await Task.WhenAll(items.Select(async i => { var items = new List <ProviderResourceSuggestion>(); try { foreach (var func in await i.ListFunctionsAsync()) { foreach (var key in await i.ListFunctionKeysAsync(func.Name)) { items.Add( new ProviderResourceSuggestion() { Configuration = new FunctionKeyConfiguration() { ResourceName = i.Name, ResourceGroup = i.ResourceGroupName, FunctionName = func.Name, FunctionKeyName = key.Key, KeyLength = key.Value.Length > 10 ? key.Value.Length : 32 }, Name = $"Function Key - {i.ResourceGroupName} - {i.Name} - {func.Name} ({key.Key})", ProviderType = this.GetType().AssemblyQualifiedName, ResourceValues = new[] { key.Value }, AddressableNames = i.EnabledHostNames.ToList() }); } } } catch (Exception) { } return items; }))).SelectMany(f => f).ToList()); }
#pragma warning disable IDE0060 // Remove unused parameter private static ProviderConfigurationViewModel GetViewModel(IServiceProvider serviceProvider, AuthJanitorProviderConfiguration config) => #pragma warning restore IDE0060 // Remove unused parameter new ProviderConfigurationViewModel() { ConfigurationItems = config.GetType().GetProperties() .Select(property => { if (!InputTypes.Any(t => t.Key.IsAssignableFrom(property.PropertyType)) || !ValueReaders.Any(v => v.Key.IsAssignableFrom(property.PropertyType))) { throw new NotImplementedException($"Provider Configuration includes Type '{property.PropertyType.Name}', which is not supported"); } var inputType = InputTypes.First(t => t.Key.IsAssignableFrom(property.PropertyType)).Value; var valueReader = ValueReaders.First(t => t.Key.IsAssignableFrom(property.PropertyType)).Value; return(new ProviderConfigurationItemViewModel() { Name = property.Name, DisplayName = property.GetCustomAttribute <DisplayNameAttribute>() == null ? property.Name : property.GetCustomAttribute <DisplayNameAttribute>().DisplayName, HelpText = property.GetCustomAttribute <DescriptionAttribute>() == null ? string.Empty : property.GetCustomAttribute <DescriptionAttribute>().Description, InputType = inputType, Options = inputType == ProviderConfigurationItemViewModel.InputTypes.Enumeration ? property.PropertyType.GetEnumValues().Cast <Enum>() .ToDictionary( k => k.ToString(), v => v.GetEnumValueAttribute <DescriptionAttribute>() == null ? v.ToString() : v.GetEnumValueAttribute <DescriptionAttribute>().Description) .Select(i => new ProviderConfigurationItemViewModel.SelectOption(i.Key, i.Value)) : new List <ProviderConfigurationItemViewModel.SelectOption>(), Value = valueReader(config, property) }); }) };
public async Task <List <ProviderResourceSuggestion> > EnumerateResourceCandidates(AuthJanitorProviderConfiguration baseConfig) { var azureConfig = baseConfig as AzureAuthJanitorProviderConfiguration; IPagedCollection <ISqlServer> items; if (!string.IsNullOrEmpty(azureConfig.ResourceGroup)) { items = await(await GetAzureAsync()).SqlServers.ListByResourceGroupAsync(azureConfig.ResourceGroup); } else { items = await(await GetAzureAsync()).SqlServers.ListAsync(); } return((await Task.WhenAll(items.Select(async i => { return (await i.Databases.ListAsync()).Select(db => new ProviderResourceSuggestion() { Configuration = new AzureSqlAdministratorPasswordConfiguration() { ResourceGroup = i.ResourceGroupName, ResourceName = i.Name, DatabaseName = db.Name, PasswordLength = 32 }, Name = $"SQL Admin - {i.ResourceGroupName} - {i.Name} (DB: {db.Name})", ProviderType = this.GetType().AssemblyQualifiedName, AddressableNames = new[] { i.FullyQualifiedDomainName } }); }))).SelectMany(f => f).ToList()); }
protected ProviderConfigurationViewModel GetViewModel(AuthJanitorProviderConfiguration config) => _configViewModelDelegate(config);
public async Task <List <ProviderResourceSuggestion> > EnumerateResourceCandidates(AuthJanitorProviderConfiguration baseConfig) { var azureConfig = baseConfig as AzureAuthJanitorProviderConfiguration; IPagedCollection <IEventHubNamespace> items; if (!string.IsNullOrEmpty(azureConfig.ResourceGroup)) { items = await(await GetAzureAsync()).EventHubNamespaces.ListByResourceGroupAsync(azureConfig.ResourceGroup); } else { items = await(await GetAzureAsync()).EventHubNamespaces.ListAsync(); } return((await Task.WhenAll(items.Select(async i => { var eventHubs = await(await GetAzureAsync()).EventHubs.ListByNamespaceAsync(i.ResourceGroupName, i.Name); return (await Task.WhenAll(eventHubs.Select(async eh => { var rules = await eh.ListAuthorizationRulesAsync(); return rules.Select(rule => new ProviderResourceSuggestion() { Configuration = new EventHubKeyConfiguration() { ResourceGroup = i.ResourceGroupName, ResourceName = eh.Name, NamespaceName = eh.NamespaceName, AuthorizationRuleName = rule.Name }, Name = $"Event Hub Key - {i.ResourceGroupName} - {eh.Name} - {eh.NamespaceName} ({rule.Name})", ProviderType = this.GetType().AssemblyQualifiedName, AddressableNames = new[] { i.ServiceBusEndpoint } }); }))).SelectMany(f => f); }))).SelectMany(f => f).ToList()); }