コード例 #1
0
        protected virtual async Task PostAuthenticate(HttpContext context)
        {
            var claimsPrincipal = context.User.Transform(_options.ClaimType);

            BedrockUser = SecurityModel.BedrockUser.CreateFromPrincipal(claimsPrincipal, _options.ClaimType);

            var bedrockIdentity  = new BedrockIdentity(BedrockUser, (ClaimsIdentity)context.User.Identity);
            var bedrockPrincipal = new BedrockPrincipal(BedrockUser, bedrockIdentity);

            bedrockPrincipal.AddIdentity(bedrockIdentity);

            context.User            = bedrockPrincipal;
            Thread.CurrentPrincipal = bedrockPrincipal;
        }
コード例 #2
0
        public override Task TokenValidated(TokenValidatedContext context)
        {
            ClaimsPrincipal = context.Principal.Transform(ClaimType);
            BedrockUser     = SecurityModel.BedrockUser.CreateFromPrincipal(ClaimsPrincipal, ClaimType);

            var bedrockIdentity  = new BedrockIdentity(BedrockUser);
            var bedrockPrincipal = new BedrockPrincipal(BedrockUser, bedrockIdentity);

            bedrockIdentity.AddClaims(ClaimsPrincipal.Claims);
            bedrockPrincipal.AddIdentity(bedrockIdentity);

            context.Principal       = bedrockPrincipal;
            Thread.CurrentPrincipal = bedrockPrincipal;
            ClaimsPrincipal         = bedrockPrincipal;

            return(base.TokenValidated(context));
        }