Copied to clipboard

Flag this post as spam?

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


  • Stefano 61 posts 311 karma points c-trib
    Mar 24, 2016 @ 15:38
    Stefano
    0

    Back office and .NET identity login conflict

    Hi everyone,

    I'm working on an Umbraco website for my company intranet. Only employees are authorised so I've set up Google OAuth and an LDAP authentication that then sign into .NET identity.

    I've then got a global AuthorizeAttribute that redirects to /Login unless it's handling a BackOfficeController request.

    It works pretty well but there seems to be a conflict with the back office. After logging in with the usual Umbraco authentication a completely blank page is shown. There are 2 errors in the console:

    1. Uncaught SyntaxError: Unexpected token < Login?ReturnUrl=%2Fumbraco%2FServerVariables%3Fumb__rnd%3D26aedbaf%26umb__rnd%3Dundefined.undefined:2

    2. No url found for api name legacyTreeJs angular.min.js?cdv=1969968925:63

    Where I suppose that the first error is causing the second one that makes angular not run and the page and remain blank. I thought that my global filter was causing a call to /umbraco/ServerVariables?umb__rnd=26aedbaf&umb__rnd=undefined.undefined to be redirected to /Login but it doesn't trigger a breakpoint in VS and even if I change the global filter to just throw an exception it just keeps happening.

    If the user is not logged into identity then it can log into the Umbraco back office just fine!

  • Streety 354 posts 562 karma points
    Mar 25, 2016 @ 15:31
    Streety
    0

    Have you decorated your controller actions with [Authorize]?

  • Stefano 61 posts 311 karma points c-trib
    Mar 29, 2016 @ 07:59
    Stefano
    0

    Hi Streety,

    No, I've applied it with an ApplicationEventHandler

    public class IdentityEventHandler : ApplicationEventHandler
    {
        protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
            GlobalFilters.Filters.Add(new IntranetAuthorizeAttribute());
        }
    }
    
  • Stefano 61 posts 311 karma points c-trib
    Mar 29, 2016 @ 12:24
    Stefano
    0

    After some more investigation I've found out that the redirect of the call to /umbraco/ServerVariables is due to

            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                LoginPath = new PathString("/Login"),
                ...
            }
    

    But now I'm not sure what to do to fix it and why is it causing problems only when I'm logged in with identity and not the other way around :(

    Tutorials like this seems to be doing pretty much what I'm doing on a similar Umbraco version.

  • Stefano 61 posts 311 karma points c-trib
    Mar 29, 2016 @ 13:11
    Stefano
    0

    I've just tried following the same tutorial from scratch with Umbraco 7.4.2 and I'm having the same problem. enter image description here

  • Stefano 61 posts 311 karma points c-trib
    Mar 29, 2016 @ 14:05
    Stefano
    100

    Seems like adding

            app.UseUmbracoBackOfficeCookieAuthentication(ApplicationContext.Current);
    

    to owin startup just solved it!

Please Sign in or register to post replies

Write your reply to:

Draft