public BedrockResourceAuthorizationManager
 (
     IClaimType claimType,
     IClaimCollectorFactory claimCollectorFactory,
     BedrockConfiguration bedrockConfiguration
 ) : base
     (
         claimType,
         claimCollectorFactory,
         bedrockConfiguration
     )
 {
 }
        public static ClaimsPrincipal Transform(this ClaimsPrincipal principal, IClaimType claimType)
        {
            var scopeClaims = principal.FindAll(claimType.ScopeClaimType).ToList();

            if (scopeClaims.Count != 1 || !scopeClaims[0].Value.Contains(' '))
            {
                return(principal);
            }

            var claim  = scopeClaims[0];
            var scopes = claim.Value.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries);
            var claims = scopes.Select(s => new Claim(claimType.ScopeClaimType, s));

            return(new ClaimsPrincipal(new ClaimsIdentity(principal.Identity, claims)));
        }
示例#3
0
 public PostAuthenticationMiddlewareOptions(IClaimType claimType)
 {
     ClaimType = claimType;
 }
示例#4
0
 public AzureAdScopeClaimTransformation(IClaimType claimType) => this.claimType = claimType;
 public BedrockBearerEvents(IClaimType claimType)
 {
     ClaimType = claimType;
 }
示例#6
0
        public static IBedrockUser CreateFromPrincipal(ClaimsPrincipal claimsPrincipal, IClaimType claimType)
        {
            var globalKey = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.Subject)?.Value;

            return(new BedrockUser
            {
                DisplayName = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.DisplayName)?.Value,
                GivenName = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.GivenName)?.Value,
                Surname = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.Surname)?.Value,
                JobTitle = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.JobTitle)?.Value,
                Emails = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.Emails)?.Value.Split(new char[] { ' ' }, StringSplitOptions.RemoveEmptyEntries),
                StreetAddress = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.StreetAddress)?.Value,
                City = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.City)?.Value,
                State = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.State)?.Value,
                PostalCode = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.PostalCode)?.Value,
                Country = claimsPrincipal.Claims.FirstOrDefault(c => c.Type == claimType.Country)?.Value,
                UserType = UserType.User,
                GlobalKey = !string.IsNullOrWhiteSpace(globalKey) ? new Guid(globalKey) : Guid.Empty
            });
        }
示例#7
0
 public ResourceAuthorizationManagerBase(IClaimType claimType, IClaimCollectorFactory claimCollectorFactory, BedrockConfiguration bedrockConfiguration)
 {
     ClaimType             = claimType;
     ClaimCollectorFactory = claimCollectorFactory;
     BedrockConfiguration  = bedrockConfiguration;
 }
        public static IApplicationBuilder UsePostAuthenticateMiddleware(this IApplicationBuilder application, IClaimType claimType)
        {
            var options = new PostAuthenticationMiddlewareOptions(claimType);

            return(application.UsePostAuthenticateMiddleware(options));
        }