我已经有了一个在asp.net & SQL下开发的5 ASP.NET应用程序。每个应用程序都有自己的私有用户表“凭据”来授权登录时的用户。
如何应用SSO解决方案来覆盖5个应用程序?知道同一用户在每个应用程序上具有不同的访问凭据,“用户名和密码”对于5个应用程序上的同一用户来说并不相同。
另外,如果有任何第三方工具可以做到这一点而不改变任何东西上的5应用程序,将非常好。
谢谢。
发布于 2017-05-05 04:51:41
您可以为此目的使用Identity Server (在这里,https://identityserver.github.io/Documentation/docsv2/是第3版的文档,您可以在应用程序中找到如何运行授权)。
身份服务器提供了IdentityServerOptions对象,您可以在其中定义一些内容。但是对于您来说,最重要的是工厂属性,您可以在这里配置身份服务器行为。
下面是一个例子:
public class Factory
{
public static IdentityServerServiceFactory Create()
{
var factory = new IdentityServerServiceFactory();
// Users are taken from custom UserService which implements IUserService
var userService = new YourUserService();
factory.UserService = new Registration<IUserService>(resolver => userService);
// Custom view service, for custom login views
factory.ViewService = new Registration<IViewService>(typeof(YourViewService));
// Register for Identity Server clients (applications which Identity Server recognize and scopes
factory.UseInMemoryClients(Clients.Get());
factory.UseInMemoryScopes(Scopes.Get());
return factory;
}
}在YourUserService将实现IUserService (由Identity Server提供)的地方,您可以根据需要授权用户,而在方法AuthenticateLocalAsync和GetProfileDataAsync中,您可以执行自己的身份验证逻辑。
工厂在身份服务器项目启动类中的应用
public void Configuration(IAppBuilder app)
{
var options = new IdentityServerOptions
{
SiteName = "IdentityServer",
SigningCertificate = LoadCertificate(),
EnableWelcomePage = false,
Factory = Factory.Create(),
AuthenticationOptions = new AuthenticationOptions
{
EnablePostSignOutAutoRedirect = true,
EnableSignOutPrompt = false,
},
};
app.UseIdentityServer(options);
}在这里,https://github.com/IdentityServer/IdentityServer3.Samples/tree/master/source/CustomUserService,您可以找到一些例子使用自己的UserService
这里还提供了更多如何使用Identity Server的https://github.com/IdentityServer/IdentityServer3.Samples示例。
唯一不好的是,在每个应用程序中,您必须使用Identity Server作为身份验证服务进行配置,因此必须更改现有的应用程序。
https://stackoverflow.com/questions/43788896
复制相似问题