我正在为OWIN和Azure Active Director实现OAuth2提供程序.FWIW,此时OpenId Connect选项不符合此工作的要求.
我获得了一个auth代码,并使用auth_code,state返回到我的回复url,并将令牌请求发送到"scheme://login.windows.net/ {myguid}/oauth2/token".
// Build up the body for the token request
var body = new List<KeyValuePair<string, string>>();
body.Add(new KeyValuePair<string, string>("grant_type", "authorization_code"));
body.Add(new KeyValuePair<string, string>("code", code));
body.Add(new KeyValuePair<string, string>("redirect_uri", redirectUri));
body.Add(new KeyValuePair<string, string>("client_id", Options.ClientId));
body.Add(new KeyValuePair<string, string>("client_secret", Options.ClientSecret));
// Request the token
HttpResponseMessage tokenResponse =
await httpClient.PostAsync(TokenEndpoint, new FormUrlEncodedContent(body));
string text = await tokenResponse.Content.ReadAsStringAsync();
tokenResponse.EnsureSuccessStatusCode();
Run Code Online (Sandbox Code Playgroud)
我收到此错误:
{"error":"invalid_resource","error_description":"AADSTS50001: Resource identifier is not provided.
Trace ID: 227f2af8-0837-4f22-ac0f-a09b3f9a6d50
Correlation ID: 3d783f11-44d0-4efa-8831-3dd581d653ed
Timestamp: 2014-08-08 21:59:49Z","error_codes":[50001],"timestamp":"2014-08-08 21:59:49Z","trace_id":"227f2af8-0837-4f22-ac0f-a09b3f9a6d50","correlation_id":"3d783f11-44d0-4efa-8831-3dd581d653ed"}
Run Code Online (Sandbox Code Playgroud)
好的,我添加了资源选项:
// Build up the …Run Code Online (Sandbox Code Playgroud) 在一个评估各种不同身份提供者的项目中,我有一个代码库已经使用WsFederation Owin包成功通过Azure AAD和Okta进行了身份验证.评估列表中的下一个是内部托管的ADFS.和前两个一样:
我进入了idp登录页面,
登录,
使用带有表单变量的POST发送回主机(在本地运行),包括wtresult表单变量中的RequestSecurityTokenResponse.
发出外部登录cookie
我的ExternalLoginCallback函数被调用
不同之处在于:
var loginInfo = await AuthenticationManager.GetExternalLoginInfoAsync();
if (loginInfo == null)
{
return RedirectToAction("Login");
}
Run Code Online (Sandbox Code Playgroud)
loginInfo为null.以下是我尚未解读的潜在线索.如果我没有设置
app.UseExternalSignInCookie(DefaultAuthenticationTypes.ExternalCookie);
Run Code Online (Sandbox Code Playgroud)
在我的初创公司中,我在User.Identity中获得了经过身份验证的声明身份.但是,此身份中没有用户名,姓名或角色声明.如果比较从Okta和ADFS返回的令牌,则有两个不同之处.两者都有upn,name和role声明,但ADFS声明是SAML 1.0声明,其中Okta是SAML 2.0.另一个区别是ADFS签名方法是sha265,其中Okta是sha1.
这些差异会导致我的问题吗?配置ADFS的人不知道指定这些东西的方法,是否可以将WsFederation中间件配置为请求特定的东西或使用ADFS正在使用的东西?