How to get remote IP Address of client in identity

2019-07-17 06:30发布

问题:

Is there a property in the context variable (ResourceOwnerPasswordValidationContext) that lets me access the IP address of the client sending the initial request for an auth.

回答1:

There is no information like that for you to grab within that context. Your only Option is to inject IHttpContextAccessor into your ResourceOwnerPasswordValidator and then you can get the request IP from the HttpContext.Request object.