【问题标题】:Custom IIdentity - where does it belong in a multi-layer application? [closed]自定义 IIdentity - 它在多层应用程序中属于什么位置? [关闭]
【发布时间】:2016-07-15 15:35:33
【问题描述】:

给定一个 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 层,但自定义逻辑(即自定义用户)不是 的东西吗?这里有点困惑......

【问题讨论】:

    标签: c# asp.net-mvc claims-based-identity separation-of-concerns multi-layer


    【解决方案1】:

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

    【讨论】:

      猜你喜欢
      • 2011-01-19
      • 2023-03-15
      • 1970-01-01
      • 2014-10-02
      • 1970-01-01
      • 2015-05-25
      • 2010-11-07
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多