我配置了一个使用AD FS的Web App,为此我使用了OWIN.
对于登录,一切都好.如果我是域名的用户并访问该网站,则会自动连接.
但我想要的是在登录后自己处理用户和角色.
所以我想用这个AD帐户检查我的数据库中是否存在用户(此过程将在另一个应用程序登录之前生成)
我想使用Microsoft的Identity来处理声明(角色和权限).但我不明白如何将我的代码用于处理来自AD FS(使用Ws-Federation)的成功连接,并添加验证并填写正确的角色.
我在ConfigureAuth中的代码:
public partial class Startup
{
private static string realm = ConfigurationManager.AppSettings["ida:Wtrealm"];
private static string adfsMetadata = ConfigurationManager.AppSettings["ida:ADFSMetadata"];
private NLogLoggingService _loggingService;
public void ConfigureAuth(IAppBuilder app)
{
_loggingService = new NLogLoggingService("Startup");
_loggingService.Debug("ConfigureAuth");
app.SetDefaultSignInAsAuthenticationType(CookieAuthenticationDefaults.AuthenticationType);
app.UseCookieAuthentication(new CookieAuthenticationOptions());
app.UseWsFederationAuthentication(
new WsFederationAuthenticationOptions
{
Wtrealm = realm,
MetadataAddress = adfsMetadata,
//CallbackPath = PathString.FromUriComponent("/Account/TestCallback"),
// https://msdn.microsoft.com/en-us/library/microsoft.owin.security.authenticationmode(v=vs.113).aspx
AuthenticationMode = AuthenticationMode.Passive,
//Notifications = new WsFederationAuthenticationNotifications
//{
//}
});
}
Run Code Online (Sandbox Code Playgroud)
在Web.config中,realm是我的Web App的链接(https://ssoadfs.test),adfsMetadata是AD FS的metadata.xml链接.
AD FS连接后设置角色和登录逻辑的方法是什么?
架构,我在想什么:
编辑:经过一些尝试,我无法处理任何成功的回调.我不想在HomeController中处理角色......
我上次的Auth配置:
_loggingService = …Run Code Online (Sandbox Code Playgroud)