根据 JWT 身份验证令牌中的声明验证来自请求的 IP
Validate IP from request against claim in JWT authentication token
我正在使用 JWT 身份验证(例如 here)开发 .Net Core Web API。
我添加了一个新的 Claim 来存储请求的 ip 地址,然后,我想在每个连续的请求上检查它以验证请求的 ip 地址源是否与最初请求令牌的 ip 相同.
为此,我进行了自定义基于策略的身份验证(例如 here), and i want to get the ip of each request on the AuthorizationHandler of the policy, but i can't get it ( 在 AuthorizationHandler 上不起作用)。
也许这不是我想要的方法,有人可以帮助我吗?
谢谢!
最后我做的是获取IP。
然后我添加一个 ActionFilterAttribute
覆盖 OnActionExecuting
在该过滤器中,我从声明中获取原始 IP 并将其与请求 IP (context.HttpContext.Connection.RemoteIpAddress
) 进行比较。
我正在使用 JWT 身份验证(例如 here)开发 .Net Core Web API。
我添加了一个新的 Claim 来存储请求的 ip 地址,然后,我想在每个连续的请求上检查它以验证请求的 ip 地址源是否与最初请求令牌的 ip 相同.
为此,我进行了自定义基于策略的身份验证(例如 here), and i want to get the ip of each request on the AuthorizationHandler of the policy, but i can't get it (
也许这不是我想要的方法,有人可以帮助我吗?
谢谢!
最后我做的是
然后我添加一个 ActionFilterAttribute
覆盖 OnActionExecuting
在该过滤器中,我从声明中获取原始 IP 并将其与请求 IP (context.HttpContext.Connection.RemoteIpAddress
) 进行比较。