zoukankan      html  css  js  c++  java
  • Identity简单授权

    详情访问官方文档

    以下代码将访问权限限制为任何经过身份验证的用户,这里为控制器级

    [Authorize]
    public class AccountController : Controller
    {
        public ActionResult Login()
        {
        }
    
        public ActionResult Logout()
        {
        }
    }

    如果要对操作(而不是控制器)应用授权,请将属性应用于方法本身

    public class AccountController : Controller
    {
       public ActionResult Login()
       {
       }
    
       [Authorize]
       public ActionResult Logout()
       {
       }
    }

    现在只有经过身份验证的用户可以访问该 Logout 函数。

    你还可以使用属性,以 AllowAnonymous 允许未通过身份验证的用户访问各个操作。

    [Authorize]
    public class AccountController : Controller
    {
        [AllowAnonymous]
        public ActionResult Login()
        {
        }
    
        public ActionResult Logout()
        {
        }
    }

    这将仅允许经过身份验证的用户 AccountController 访问,但 Login 操作除外,无论用户是否经过身份验证或未经身份验证/匿名状态,都可以访问该操作。

  • 相关阅读:
    2019届宝鸡理数质检Ⅱ解析版
    随机事件的概率
    三视图
    求曲线的轨迹方程
    组合法破解二项式系数问题
    二项式定理
    计数原理
    HBase的Shell命令
    HBase伪分布安装
    HBase基础知识
  • 原文地址:https://www.cnblogs.com/liessay/p/13213573.html
Copyright © 2011-2022 走看看