witoldsz / angular-http-auth

MIT License
2.38k stars 418 forks source link

Redirection-based SSO solutions? #65

Open kastork opened 10 years ago

kastork commented 10 years ago

Hi,

Any ideas how this would all work with a redirection-based SSO protocol like CAS? In these systems, the login takes place on a page served by the IDP website (i.e., not your app), then your browser gets redirected back to your app with a token in the query string -- you never see the username / password, and couldn't do anything useful with it even if you did.

witoldsz commented 10 years ago

I am not sure, but how about this:

Does it sound good? I have never done it, but why shouldn't it work this way?

kastork commented 10 years ago

Hmm, maybe... The redirect back from the IDP contains a token that you need to process -- this is a URL you define, but it is going to be in the window that went to the external URL. (Your client app isn't present in that window, and also the redirect is real, not an XHR request). I think that return trip would have to cause the client app to load in order to feed it the info needed for the rest of your system to work as designed. Maybe we're talking about multiple endpoints -- a token vendor endpoint that does the redirection dance but doesn't contain the SPA, when satisfied it redirects your browser to the real SPA with token data in the headers for consumption by your scheme.

witoldsz commented 10 years ago

Why this should be problem? Once the CAS service redirects back to your page, your app will establish a SSO cookie. After it happens, you can close that window, go back to your app and it will receive this cookie on next server call. Once you get redirected from CAS back to your app (it does not matter which browser window or tab it was), you are effectively authenticated.

It seems there is no need to relaunch your application. It can continue working. After you are authenticated, you can tell it to the authService.loginConfirmed([data],[configUpdater]) and it should resend all the failed requests, so your services and controllers won't even notice the login operation happened.

alexcrown commented 9 years ago

Jasig CAS has REST API. You can use it like this gist.