Skip to content

Proof of concept of a role-based authorization of the secret providers registered in the Arcus secret store by low-level customization.

License

Notifications You must be signed in to change notification settings

stijnmoreels/arcus.security.authorization-poc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Arcus.Security.Core.Authorization

Example of how the Arcus secret store can be customized to include authorization on provider-level.

public class Program
{
    public static void Main(string[] args) =>
        CreateHostBuilder(args).Build().Run();

    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureAppConfiguration((context, config) => 
            {
                config.AddJsonFile("appsettings.json")
                      .AddJsonFile("appsettings.Development.json");
            })
            .ConfigureServices(services => services.AddSingleton(new FixedRoleAuthorization(Role.Writer))
            .ConfigureSecretStore((IConfiguration config, SecretStoreBuilder secretStoreBuilder) =>
            {
#if DEBUG
                secretStoreBuilder.AddConfiguration(config);
#endif
                var keyVaultName = config["KeyVault_Name"];
                secretStoreBuilder.AuthorizedWithin(Role.Writer, builder => 
                    builder.AddAzureKeyVaultWithManagedServiceIdentity($"https://{keyVaultName}.vault.azure.net"));
                    
                secretStoreBuilder.AuthorizedWithin(Role.Admin, builder => builder.AddEnvironmentVariables();
            })
            .ConfigureWebHostDefaults(webBuilder => webBuilder.UseStartup<Startup>());
}

About

Proof of concept of a role-based authorization of the secret providers registered in the Arcus secret store by low-level customization.

Topics

Resources

License

Stars

Watchers

Forks

Languages