Course contentsShow
← C#
Lesson 1225 of 1,90811. Identity, Security, and ClaimsFree lesson

Delegation of Authority Patterns

Design secure ways for users to delegate specific actions to other users.

In this lesson, you will learn how to implement secure delegation patterns that allow users to grant temporary or scoped authority to others without sharing their primary identity credentials.

Understanding Delegation of Authority

Delegation occurs when a user (the Delegator) needs to authorize another user (the Delegatee) to perform actions on their behalf. In an enterprise system, you shouldn't just "hand over" a role; you need a granular, time-bound, and auditable way to transfer specific permissions.

The most effective pattern for this is the Proxy Token Pattern. Instead of simply changing a user's role in the database, we issue a specific authorization claim that identifies the Delegatee, the Delegator, and the scope of the authority granted.

Implementing the Delegation Claim

When a user delegates a task, we create a specialized claim that acts as a "permission ticket." Here is how you might structure the creation of this authorization metadata:

public void CreateDelegation(string delegatorId, string delegateeId, string resourceScope)
{
    // We create a custom claim that encapsulates the delegation context
    var delegationClaim = new Claim("delegated_authority", 
        $"{delegatorId}:{resourceScope}", 
        ClaimValueTypes.String);

    // This claim is attached to the delegatee's session or policy evaluation
    // During authorization, the policy checks if the delegatee holds 
    // a valid ticket for the requested resource.
}

Enforcing Scoped Authority

Once the claim is issued, your AuthorizationHandler must be updated to respect these chains. When the delegatee attempts to access a resource, your policy-based authorization logic evaluates two things:

  1. Does the delegatee have the delegated_authority claim for this specific resource?
  2. Does the original delegator still possess the rights they attempted to delegate?

By using Claims Transformation, you can inject these dynamic delegation claims into the ClaimsPrincipal at runtime. This keeps the authorization logic clean because the rest of your application simply checks for the permission, unaware—and unconcerned—that the authority was delegated rather than owned directly.

Always ensure these delegations are stored with an expiry timestamp. If a user revokes access or the delegator’s own permissions change, the system must perform an audit check to invalidate the delegated_authority claim immediately.

Key Takeaway: Delegation is not about assigning roles; it is about issuing time-bound, scoped claims that authorize a delegatee to act on behalf of a delegator within the bounds of a strict, auditable policy.