Ejemplo n.º 1
0
        public override Task GrantCustomExtension(OAuthGrantCustomExtensionContext context)
        {
            var windowsPrincipal = context.OwinContext.Authentication.User as WindowsPrincipal;

            if (windowsPrincipal == null)
            {
                context.SetError("User is not a Windows user");
                return(Task.FromResult(0));
            }

            var subject = SubjectGenerator.Create(windowsPrincipal, _options);

            context.Validated(subject);

            return(Task.FromResult(0));
        }
        public override async Task GrantCustomExtension(OAuthGrantCustomExtensionContext context)
        {
            var windowsPrincipal = context.OwinContext.Authentication.User as WindowsPrincipal;

            if (windowsPrincipal == null)
            {
                context.SetError("User is not a Windows user");
                return;
            }

            var subject = SubjectGenerator.Create(windowsPrincipal, _options);
            var transformationContext = new CustomClaimsProviderContext
            {
                WindowsPrincipal = windowsPrincipal,
                OutgoingSubject  = subject
            };
            await _options.CustomClaimsProvider.TransformAsync(transformationContext);

            context.Validated(transformationContext.OutgoingSubject);
        }