Table of Contents

Class ScopeRegistry

Namespace
Tharga.Team
Assembly
Tharga.Team.dll

Stores scope definitions and resolves effective scopes for a given access level. Owner and Administrator get all registered scopes. User gets scopes registered at User or Viewer level. Viewer gets only scopes registered at Viewer level. Custom gets no base scopes at all (exempt from the Owner/Administrator all-scopes rule); its effective scopes come solely from roles and scope overrides. Grant-only scopes (RegisterGrantOnly(string, string)) are granted by no access level, Owner and Administrator included; they too are held solely through roles and scope overrides. Role scopes are unioned with access level scopes.

public class ScopeRegistry : IScopeRegistry
Inheritance
ScopeRegistry
Implements
Inherited Members

Properties

All

public IReadOnlyList<ScopeDefinition> All { get; }

Property Value

IReadOnlyList<ScopeDefinition>

Groups

The groups scopes are shown under, in the order the host defined them. Empty when the host defined none.

public IReadOnlyList<ScopeGroup> Groups { get; }

Property Value

IReadOnlyList<ScopeGroup>

Methods

DefineGroup(string, string)

Defines a group scopes can be shown under. Groups are shown in the order they are defined.

public void DefineGroup(string key, string displayName)

Parameters

key string

The key scopes name when registered with a group.

displayName string

The heading, in English. Localised through the text provider under TextKeyFor(string).

Remarks

Display only. A scope naming a group that was never defined is still shown, under its key and after the defined groups, so a typo is visible rather than lost.

GetEffectiveScopes(AccessLevel?, IEnumerable<string>, IEnumerable<string>)

The scopes a member holds from their level, roles and overrides. Empty for a null level, roles and overrides included: an unset level is a record nobody finished, and its extras must not make it worth something.

public IReadOnlyList<string> GetEffectiveScopes(AccessLevel? accessLevel, IEnumerable<string> roleNames, IEnumerable<string> scopeOverrides = null)

Parameters

accessLevel AccessLevel?
roleNames IEnumerable<string>
scopeOverrides IEnumerable<string>

Returns

IReadOnlyList<string>

GetScopesForAccessLevel(AccessLevel?)

The scopes accessLevel grants on its own. Empty for null: an unset level grants nothing.

public IReadOnlyList<string> GetScopesForAccessLevel(AccessLevel? accessLevel)

Parameters

accessLevel AccessLevel?

Returns

IReadOnlyList<string>

Register(string, AccessLevel, string)

public void Register(string scopeName, AccessLevel defaultMinimumLevel, string description = null)

Parameters

scopeName string
defaultMinimumLevel AccessLevel
description string

Register(string, AccessLevel, string, string)

Registers a scope shown under group. See DefineGroup(string, string).

public void Register(string scopeName, AccessLevel defaultMinimumLevel, string description, string group)

Parameters

scopeName string
defaultMinimumLevel AccessLevel
description string
group string

RegisterGrantOnly(string, string)

Registers a scope that no access level grants. The entry exists for documentation and validation: the scope appears in the catalogue with its description and can be validated against, but it is exempt from the Owner/Administrator all-scopes rule, rejected in tenant-defined custom roles, and not offered by the scope-override pickers.

public void RegisterGrantOnly(string scopeName, string description = null)

Parameters

scopeName string

The scope name, as checked by RequireScopeAttribute.

description string

Human-readable description, shown in the scope catalogue.

Remarks

Use this for a scope that should be held only as a recorded decision — one reaching regulated or classified records, say, where "a team administrator gets it automatically" is the wrong default. Grant it by naming it on a code-registered tenant role (ITenantRoleRegistry) or through an explicit scope override; enforcement via RequireScopeAttribute is unchanged, since the scope is checked from the claim rather than from this registry.

Do not attempt the same thing by registering at Custom. That grants the scope to every level: Owner and Administrator take all registered scopes regardless of the declared minimum, and the fall-through filter DefaultMinimumLevel >= accessLevel is satisfied by Custom for User and Viewer too.

RegisterGrantOnly(string, string, string)

Registers a grant-only scope shown under group. See RegisterGrantOnly(string, string).

public void RegisterGrantOnly(string scopeName, string description, string group)

Parameters

scopeName string
description string
group string

SetRoleRegistry(ITenantRoleRegistry)

public void SetRoleRegistry(ITenantRoleRegistry roleRegistry)

Parameters

roleRegistry ITenantRoleRegistry