Environment:
-
ADFS 3.0(在SQL Server 2012上),没有设备注册服务
-
我们在ADFS中定义了一个依赖信任方,其TokenLifetime为1440分钟(1天) .
-
ASP.NET Web Api配置为与OWIN一起使用
-
OAuth2
-
Windows Store应用程序使用的Web Api(8.1 / 10)
Current situation:
我们在App,Web-api和ADFS之间使用OAuth2进行了身份验证流程 . 在App_Start \ Startup.Auth中的启动类中的web-api中,我们有以下代码:
public void ConfigureAuth(IAppBuilder app)
{
app.UseActiveDirectoryFederationServicesBearerAuthentication(
new ActiveDirectoryFederationServicesBearerAuthenticationOptions
{
MetadataEndpoint = ConfigurationManager.AppSettings["ida:AdfsMetadataEndpoint"],
TokenValidationParameters = new TokenValidationParameters()
{
ValidAudience = ConfigurationManager.AppSettings["ida:Audience"]
}
});
}
在 web.config
中我们配置了 appsettings
:
<add key="ida:AdfsMetadataEndpoint" value="https://adfs.service.com/federationmetadata/2007-06/federationmetadata.xml" />
<add key="ida:Audience" value="http://orderapi.service.com" />
Wanted situation:
当应用程序使用某些重要 endpoints 时,我们有需求,即不到7分钟前用户已经过身份验证/登录 . 对于其他不太重要的 endpoints ,这不是问题,一天就足够了 .
我们最初的教导是在ADFS中创建一个额外的依赖信任方,使用不同的令牌生命周期(7分钟) . 同样在 endpoints 级别,我们在de Web-api中定义了两个不同的URL:
-
长令牌生命周期 - >可以与长令牌生命周期一起使用的每个 endpoints 都以https://webapi.service.com/api_long/开头....( - > https://webapi.service.com/api_long/Order/Get)
-
短令牌生命周期 - >每个需要短令牌生命周期的 endpoints 都以https://webapi.service.com/api_short/开头...( - > https://webapi.service.com/api_short/Order/Post)
Question / Problem:
-
是否可以通过一个Web-api与同一个ADFS上的2个依赖信任方合作?
-
如果可能,您如何在创业级注册两个信赖方?
-
如何告诉控制器它必须使用哪个依赖信任方的行动?
-
如果无法通过一个Web-api在同一个ADFS上与2个依赖信任方合作,那么还有另一个可以帮助我们的解决方案吗?
-
我自己的替代方案是制作2个Web-api,一个用于长,一个用于短 . 但不知何故,我找不到一个优雅的解决方案 .
在此先感谢您的帮助 .