Table of Contents

Class RoleServiceCollectionExtensions

Namespace
Microsoft.Extensions.DependencyInjection
Assembly
Excalibur.A3.Core.dll

Extension methods for registering role management on IA3Builder.

public static class RoleServiceCollectionExtensions
Inheritance
RoleServiceCollectionExtensions
Inherited Members

Methods

AddRoles(IA3Builder, IConfiguration)

Adds role management services to the A3 builder using an IConfiguration section.

[RequiresUnreferencedCode("Binding configuration to the options type reflects over its members, which trimming may remove. Configure the options in code instead of binding IConfiguration.")]
[RequiresDynamicCode("Binding configuration to the options type can require runtime code generation, which native AOT does not support. Configure the options in code instead of binding IConfiguration.")]
public static IA3Builder AddRoles(this IA3Builder builder, IConfiguration configuration)

Parameters

builder IA3Builder

The A3 builder.

configuration IConfiguration

The configuration section to bind to RoleOptions.

Returns

IA3Builder

The IA3Builder for fluent chaining.

AddRoles(IA3Builder, Action<RoleOptions>?)

Adds role management services to the A3 builder.

public static IA3Builder AddRoles(this IA3Builder builder, Action<RoleOptions>? configure = null)

Parameters

builder IA3Builder

The A3 builder.

configure Action<RoleOptions>

Optional delegate to configure RoleOptions.

Returns

IA3Builder

The IA3Builder for fluent chaining.

Remarks

Registers IRoleStore with an in-memory fallback store and decorates IAuthorizationEvaluator with a role-aware evaluator that resolves GrantType.Role grants to effective permissions at authorization time.

services.AddExcaliburA3Core()
    .AddRoles(opts =>
    {
        opts.MaxHierarchyDepth = 3;
        opts.EnforceUniqueNames = true;
        opts.PermissionCacheDurationSeconds = 600;
    });