0

给定一个 3 层架构:

  • 域逻辑层
  • 数据访问层
  • 用户界面层(ASP.NET MVC Web 应用)

放置与构建自定义用户身份、添加自定义声明并将其签名到 Web 应用程序相关的逻辑的正确位置是什么?

例如,这样的逻辑:

if (something)
    customClaim = new Claim("MyClaimType1", "SomeClaimValue");
else
    customClaim = new Claim("MyClaimType2", "AnotherClaimValue");

customClaimsIdentity.AddClaim(customClaim);
HttpContext.Current.GetOwinContext().Authentication.SignIn(customClaimsIdentity);

我想说的是 UI 层,但自定义逻辑(即自定义用户)不是领域的东西吗?这里有点迷茫...

4

1 回答 1

1

您所描述的是通常与 ASP.NET MVC 相关联的安全横切关注点,并且通常作为操作过滤器实现。基于此,您显示的代码(也直接使用)HttpContext应该位于用户界面层(ASP.NET MVC Web 应用程序)中。

于 2016-07-15T15:57:15.223 回答