Does anyone have any tips on how to use .Net Identity authentication with AngularJS? I'm a complete newbie to both Angular and .Net that is using the Hot Towel Angular SPA Template ( https://github.com/johnpapa/HotTowel-Angular ) as a basis for an application. The .Net views are easily configurable to redirect to a login page with the [Authorize] attribute, but I don't know how to integrate this at all with the Angular front-end. The easiest solution seems like it would be to somehow redirect the main Angular page (index.html) to the .Net Razor home page if there's no user logged in. I don't really care if this login page is in a different layout, and I don't need/want to use razor views for anything else but I want the main app to be SPA. "Great" security is not really that important either, since this application will mostly be used internally; for now I just need something that works OK. [.m] we are currently using the new Asp.Net Identity engine, well we are only leveraging the power of OWIN security and not the UserManager/UserStore features, but this is another story. We have approached it in the following manner:
- Server side we use the Authorize attribute; - When a user is not authorized OWIN security redirects, exactly as FormsAuthentication does, to the login MVC route; - The login page is another AngularJS app, with its own lifecycle, completely separated from the “real” app; - If the login is successful the login-app simply redirects to “/”, MVC kicks in and the authorization starts again if everything is ok the “real” app is loaded; - At each request done to WebAPI the browser sends back cookies, and thus also the authentication cookies, so we can decorate even WebAPI with the Authorize attribute; - In this latter case if authorization fails at WebAPI requests the “real” app simply shows a message to the user; Makes sense? .m -- You received this message because you are subscribed to the Google Groups "AngularJS" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/angular. For more options, visit https://groups.google.com/groups/opt_out.
