ASP.NET Web API Login History Implementation -
ASP.NET Web API Login History Implementation -
i have searched have not found documentation outlining best way log each successful or failed effort access token , store date/time , ip of request. able within application?
ok. it's odd there isn't involvement in answering question.
after trial/error , debug tracing, found applicationoauthprovider
, located in providers
folder in typical asp.net web api template, contains following:
public override async task grantresourceownercredentials(oauthgrantresourceownercredentialscontext context) { var usermanager = context.owincontext.getusermanager<applicationusermanager>(); applicationuser user = await usermanager.findasync(context.username, context.password); //log authentication effort here if (user == null) { context.seterror("invalid_grant", "the user name or password incorrect."); return; } claimsidentity oauthidentity = await user.generateuseridentityasync(usermanager, oauthdefaults.authenticationtype); claimsidentity cookiesidentity = await user.generateuseridentityasync(usermanager, cookieauthenticationdefaults.authenticationtype); authenticationproperties properties = createproperties(user.username); authenticationticket ticket = new authenticationticket(oauthidentity, properties); context.validated(ticket); context.request.context.authentication.signin(cookiesidentity); }
i set comment in code show logging implemented. hope helps.
login asp.net-web-api oauth-2.0
Comments
Post a Comment