dotnet/aspnetcore

IClaimsTransformation do not automagically compose

オープン

#46,120 opened on 2023/01/16

 (19 件のコメント) (25 件のリアクション) (0 人の担当者)C# (10,653 件のフォーク)batch import
Pillar: Dev Experiencearea-authenhancementhelp wanteduntriaged

Repository metrics

Stars
 (37,933 個のスター)
PR merge metrics
 (PR metrics pending)

説明

Is there an existing issue for this?

  • I have searched the existing issues

Is your feature request related to a problem? Please describe the problem.

Multiple registrations on IClaimsTransformation should compose. For pete's sake, the signature for IClaimsTransformation is literally an async reduce function.

Describe the solution you'd like

A ReducerClaimsTransformer should be injected into AuthenticationService.Transform

public class ReducerClaimsTransformation : IClaimsTransformation
{
    public async Task<ClaimsPrincipal> TransformAsync(ClaimsPrincipal principal)
    {
        foreach (var transformation in _transformations)
        {
            principal = await transformation.TransformAsync(principal);
        }

        return principal;
    }
}

Additional context

No response

コントリビューターガイド