2

什么是单点登录 (SSO)?

单点登录 (SSO) 是一种会话和用户身份验证服务,它允许用户使用一组登录凭证(例如,名称和密码)来访问多个应用程序。

使用单点登录可以消除多次登录,即用户只需登录一次即可访问多个 Web 应用程序。在 ASP.NET MVC 中使用 ITfoxtec SAML 2.0 实现 SSO 非常简单。下面是逐步实现它的方法。

  1. 打开visual studio,创建一个ASP.net MVC Application 在此处输入图像描述

  2. 从 nuget pacakges 添加 itfoxtec.saml2 和 itfoxtec.saml2.mvc 在此处输入图像描述

  3. 检查控制器文件夹中的 AuthController 在此处输入图像描述

  4. 设置基本设置,如 Issuer url、Destination、AssertionConsumerServiceUrl

  5. 使用下面给出的代码在 AssertionConsumerService 方法中获取身份

    var useridentity = saml2AuthnResponse.ClaimsIdentity as ClaimsIdentity; var username = useridentity.Claims.Where(c => c.Type == "username") .Select(c => c.Value).SingleOrDefault();

4

0 回答 0