Ser*_*e P 13 .net c# authentication owin
使用Owin Security,我试图让API有2种身份验证方法.
context变量(OAuthGrantResourceOwnerCredentialsContext)中是否有一个属性可以让我访问客户端的IP地址,向API发送auth令牌的初始请求?
我的auth方法的基本条带如下所示:
public override async Task GrantResourceOwnerCredentials(
OAuthGrantResourceOwnerCredentialsContext context)
{
await Task.Run(() =>
{
var remoteIpAddresss = context.Request.RemoteIpAddress;
var localIpAddress = context.Request.LocalIpAddress;
// ... authenticate process goes here (AddClaim, etc.)
}
}
Run Code Online (Sandbox Code Playgroud)
根据我的理解remoteIpAddress和localIpAddressAPI(即API的托管位置).我如何知道请求从哪个IP地址(和端口)发送?
客户是否需要自己发送此信息?
我应该在auth路径中添加额外的参数吗?(除了典型username,password,grant_type)?
Ser*_*e P 20
所以,要回答我自己的问题,请纠正我,如果我错了,但是:
var remoteIpAddresss = context.Request.RemoteIpAddress;
Run Code Online (Sandbox Code Playgroud)
是客户端的IP地址(请求身份验证令牌的用户),以及
var localIpAddress = context.Request.LocalIpAddress;
Run Code Online (Sandbox Code Playgroud)
是Web Api的IP地址(托管API的地方).
| 归档时间: |
|
| 查看次数: |
8599 次 |
| 最近记录: |