How do I prevent the AngularJS route from being re-authenticated using server side SSO?

I have installed an AngularJS app that uses the following routing configuration in a module:

$stateProvider.
    state('home', {
        url: '/',
        templateUrl: 'public/modules/core/views/home.client.view.html'
    }).
    state('page2', {    
        url: '/test',
        templateUrl: 'public/modules/core/views/test.client.view.html'
    });

      

My web server has SSO software that forces me to login and, if allowed, will set the user information in the request headers and redirect me to the requesting page. So, the first time I click on the app ( http://---.-------.com ), I log in and is redirected to the home page above. Angular works fine and loads the correct template. However, when I click on the link on the page pointing to / test (the second template to download), for whatever reason, it tries to re-authenticate and I get a cross domain exception in the browser console.

I thought AngularJS would load the second template when I click the link on the link without reloading the page so that the server side SSO does not restart. When I nested the template in the original html file, I was able to load the template without any problem, but I plan on having many templates and would like the templates to be separated in their own files.

Can anyone see how I can store templates in my own files, but not let SSO run on every redirect through AngularJS?

----- Clarification: So, after the start character, a cookie is provided. Maybe I just don't understand how to get Angular ui-router to use this cookie, which should be part of subsequent requests. How is this usually done?

+3


source to share


1 answer


It will likely be a configuration issue for your server if you don't have custom JS code to handle the request (like Angular's request-interceptors). I use $stateProvider

just like you and mine just worked well.

One possibility is that your server is configured to force authentication every time a page is requested HTML

. Easy to check - after logging in, refresh the current page. If you are asked to login again, this is the problem.



The solution depends on your sever technology. A workaround is to rename test.client.view.html to test.client.view. js and update templateUrl

as your js download seems fine.

This is my best guess without further details. Hope it helps.

0


source







All Articles