asp.net mvc - Security check an User to a access controller action -
hello guys have mvc actions have authorize attribute set on them. each 1 of these actions there password/ security pin valid action.
public actionresult action_1()// generic pin 1 { return redirecttoaction("pincheck", new { returnurl = "action_1" }); ... } [authorize] public actionresult action_2()// generic pin 2 { ... } [authorize] public actionresult pincheck(string returnurl)// generic pin 1 { // request 3 characters of pin in random. ... } [authorize] [httppost] public actionresult pincheck(string a, string b, string c, string returnurl)// generic pin 1 { // check 3 chars. ... // how store pin check controller success , don't ask user unless closes browser or logout } my plan of action checking pins stored admin particular user particular action in database. far have achieved checking pincheck() routine problem face user has enter pin every time requests particular action. made way around saving encrypted cookie on pincheck success. there way modify authorize attribute , authentication cookie achieve doing?
you can represent each pin verified claim stored part of claimsidentity in cookie can query against user's claims looking appropriate pinclaim in each action. if using asp.net identity, can when verify pin:
await manager.addclaimasync(user.identity.getuserid(), new claim("<mypinclaim>", "<value>")) await signinasync() // , resign user in regenerate cookie claim
Comments
Post a Comment