如何在身份服务器4中获取客户端的远程IP地址 [英] How to get remote IP Address of client in identity server 4

查看:81
本文介绍了如何在身份服务器4中获取客户端的远程IP地址的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

上下文变量(ResourceOwnerPasswordValidationContext)中是否有一个属性,可让我访问发送初始身份验证请求的客户端的IP地址.

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.

推荐答案

在该上下文中没有可供您获取的类似信息.唯一的选择是将IHttpContextAccessor注入到ResourceOwnerPasswordValidator中,然后可以从HttpContext.Request对象获取请求IP.

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.

这篇关于如何在身份服务器4中获取客户端的远程IP地址的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆