由于某些原因,OWIN无法重定向到ADFS中指定的登录页面,我对ADFS没有任何控制权(Windows Server 2012),我遵循了Microsoft文档(http://www.asp.net/visual-studio/overview/ 2013 / creating-web-projects-in-visual-studio#orgauthonprem),但我现在停滞了。我认为通过引用元数据,所有内容都可以即开即用地配置。
我的控制器(从WebApi生成的模板)
[Authorize]
public class ValuesController : ApiController
{
// GET api/values
public IEnumerable<string> Get()
{
return new string[] { "value1", "value2" };
}
// GET api/values/5
public string Get(int id)
{
return "value";
}
// POST api/values
public void Post([FromBody]string value)
{
}
// PUT api/values/5
public void Put(int id, [FromBody]string value)
{
}
// DELETE api/values/5
public void Delete(int id)
{
}
}
但是我明白了
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Error>
<Message>Authorization has been denied for this request.</Message>
</Error>
我应该实施某种基于身份的身份验证吗?
更新!
似乎有必要Microsoft.Owin.Security.WsFederation
但是,现在adfs不再重定向到我的境界了,在对用户进行身份验证之后,我从ADFS中获得了302。
/adfs/ls/?wtrealm=http%3a%2f%2flocalhost%3a554&wctx=WsFedOwinState%3d9C7kwsHRjBM86yrii5niUWF1gW9VFvCKBTj_D3z4-QQ5P25opteVK0mWf0fudEQdsgIexkHxTxhKDqBmfSWNAuJ3togHTBE40CEKYa8JLKJOxsgxNGIreYBOzNYzK8NNvR26PCMCowCFoM9NGJOC8w&wa=wsignin1.0
我的Startup.cs
public partial class Startup
{
// For more information on configuring authentication, please visit http://go.microsoft.com/fwlink/?LinkId=301864
public void ConfigureAuth(IAppBuilder app)
{
app.SetDefaultSignInAsAuthenticationType(WsFederationAuthenticationDefaults.AuthenticationType);
app.UseWsFederationAuthentication(new WsFederationAuthenticationOptions
{
MetadataAddress = ConfigurationManager.AppSettings["ida:AdfsMetadataEndpoint"],
Wtrealm = ConfigurationManager.AppSettings["ida:Audience"],
});
app.UseCookieAuthentication(new CookieAuthenticationOptions
{
AuthenticationType = WsFederationAuthenticationDefaults.AuthenticationType
});
}
}
我如何告诉ADFS重定向到领域?
事实证明,ADFS需要一个具有唯一ID的依赖方来验证用户身份并正确重定向到该领域。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句