Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Marcel Wege 4 posts 84 karma points
    Feb 24, 2018 @ 15:08
    Marcel Wege
    0

    Custom OWIN Backoffice Authentication

    Hey everyone,

    I have some weired problems or misunterstanding with my OWIN Implementation. I build up a middleware after reading many examples.

    In the AuthenticateCoreAsync function, I get a complete AuthenticationTicket based on the UmbracoBackOfficeIdentiy, but I am not logged in. Do I miss some steps?

    Attach you will find my AuthenticationHandler Implementation.

    (Code is just for understanding and debugging)

    Thx in advance

    Regards

    Marcel

    protected override Task<AuthenticationTicket> AuthenticateCoreAsync()
        {
            if (ShouldAuthRequest())
            {
                var authTicket = GetAuthTicket(Request, UmbracoConfig.For.UmbracoSettings().Security.AuthCookieName);
                if (authTicket != null)
                {
                    return Task.FromResult(new AuthenticationTicket(authTicket, new AuthenticationProperties()));
                }
            }
    
            return Task.FromResult<AuthenticationTicket>(null);
    
        }
    
    private UmbracoBackOfficeIdentity GetAuthTicket(IOwinRequest request, string cookieName)
        {
            if (request == null) throw new ArgumentNullException("request");
    
            var signManager = Context.GetBackOfficeSignInManager();
            var userManager = Context.GetBackOfficeUserManager();
            var identityUser = userManager.FindByEmail("[email protected]");
            var claim = identityUser.GenerateUserIdentityAsync(userManager);
            var authorisation = (UmbracoBackOfficeIdentity)claim.Result;
    
            return authorisation;
        }
    
  • This forum is in read-only mode while we transition to the new forum.

    You can continue this topic on the new forum by tapping the "Continue discussion" link below.

Please Sign in or register to post replies