jeudi 19 janvier 2017

web api serialize property value by claim

I have a web api and this model

{
  public string Username { get; set; }
  [MyCustomDataAnnotation]
  public string Password { get; set; }
}

I need to render Password value by claim auth. If I am a member of "administrators" group I can view the password, but if I'm not an Administrator I can't view the value

This is what I expect when I am an Administrator

{ Username: "Jack", Password: "123456" }

This is what I expect when I am NOT an Administrator

{ Username: "Jack", Password: null }

How can I do this? Please, consider that there are a lot of groups (no massive "if" please), the best way is having something like this Creating custom Claims Authorization attribute Thanks




Aucun commentaire:

Enregistrer un commentaire