2

I have been reading a bunch of different posts and questions all over. I am new to Angular and looking for an example on how to secure an angular application with roles.

The little I have seen on the internet involves using a service to authenticate and get the user a token; I am presuming this token is then kept in a Angular service for the duration of the users session.

I'd like a example on how to set-up both the client side (angular) routing and model security (show / hide / enable / disable specific fields) and server side (web API).

What I have in mind so far is:

  1. Create a Security controller that a login form will post to and implement logic to issue a token
  2. Secure the remaining WebApi controllers with an Authorization attribute that will issue 403 where a token is missing / invalid
  3. Implement server side processing for resources (when authorized) that returns models and only the properties a user is authorized to see (customs data annotations on the model properties)
  4. Implement 403 handling on the client (not sure where to start here)
  5. Implement view rendering of the models where fields can be enabled / disabled based on roles (i.e. user can see but not edit) (directive(s))?

A concrete example on how to do this (correctly) - taking into account the current security precautions would be helpful.

JDBennett
  • 1,323
  • 17
  • 45
  • If your client side Angular is in the same host with Web API, stick with cookie authentication is simpler, though – cuongle Aug 27 '16 at 21:28

0 Answers0