当前位置: 首页 > news >正文

网站做标签网页是怎么制作的

网站做标签,网页是怎么制作的,淘宝客怎么自己做网站,上海环球金融中心多少层目录 🍻前言 🍸一、鉴权(Authorization) 🍺二、功能实现 2.1 环境准备 2.2 代码实现 2.3 测试接口 🍹三、测试功能 3.1 传递 admin 请求 ​ 3.2 传递普通 user 请求 🍻四、章末 &a…

目录

🍻前言

🍸一、鉴权(Authorization)

🍺二、功能实现

        2.1 环境准备

        2.2 代码实现

        2.3 测试接口

🍹三、测试功能

        3.1 传递 admin 请求

​        3.2 传递普通 user 请求

🍻四、章末


🍻前言

        小伙伴们大家好,最近有一段时间没更了,有一部分是工作上的原因,还有一部分生活上的小事给耽搁了,之前的文章链接如下,这次继续来学习下 Spring EL 表达式的另一种方式,结合切面类实现鉴权的功能;

【Spring EL<一>✈️ 】SL 表达式的应用-CSDN博客

🍸一、鉴权(Authorization)

       也称为授权,是系统安全中的一个重要环节。用于确定已经通过认证的用户是否有权限访问某个资源或执行某个操作。鉴权确保只有具有适当权限的用户可以执行特定的操作,从而保护系统的资源和数据。

下面是一些常见的鉴权方式

  1. 基于角色的访问控制(RBAC)

    • 用户被赋予一个或多个角色,每个角色拥有一组权限。
    • 鉴权时根据用户的角色来决定其是否有权限执行某操作。
  2. 基于属性的访问控制(ABAC)

    • 检查用户属性、环境属性、资源属性等多种因素。
    • 使用这些属性和策略规则来进行复杂的鉴权决策。
  3. 访问控制列表(ACL)

    • 每个资源有一个列表,列出哪些用户或系统进程对该资源有哪些权限。
    • 直接针对资源的授权管理。

🍺二、功能实现

        本地实现的是基于角色访问控制的鉴权

        2.1 环境准备

        创建一个简单的 Springboot 项目,确保可以正常启动

        引入AOP 的依赖以及打开使用权限

        2.2 代码实现

                2.2.1 注解定义

                简单定义了一个注解,指明了该注解的作用域为方法上,并且运行时可存在

import java.lang.annotation.*;@Target(ElementType.METHOD)
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface CheckPermission {String value();
}

                 2.2.2 注解切面类实现

                这里没有使用切入点(@PointCut),是因为该切面类中只有一个 @Before 操作,如果有多个操作,适合使用 @PointCut 标注,就不用每个方法上都加 "@annotation(com.example.demo.testCode.springel.CheckPermission)" 了

import org.aspectj.lang.JoinPoint;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.reflect.MethodSignature;
import org.springframework.expression.ExpressionParser;
import org.springframework.expression.spel.standard.SpelExpressionParser;
import org.springframework.expression.spel.support.StandardEvaluationContext;
import org.springframework.stereotype.Component;import java.lang.reflect.Method;@Aspect
@Component
public class PermissionAspect {@Before("@annotation(com.example.demo.testCode.springel.CheckPermission)")public void checkUserPermission(JoinPoint joinPoint) throws Throwable {MethodSignature signature = (MethodSignature) joinPoint.getSignature();Method method = signature.getMethod();CheckPermission checkPermission = method.getAnnotation(CheckPermission.class);String spelExpression = checkPermission.value();// 使用Spring EL表达式解析器ExpressionParser parser = new SpelExpressionParser();StandardEvaluationContext context = new StandardEvaluationContext();// 将方法参数放入上下文中Object[] args = joinPoint.getArgs();String[] paramNames = signature.getParameterNames();for (int i = 0; i < args.length; i++) {context.setVariable(paramNames[i], args[i]);}// 模拟权限检查逻辑Boolean hasPermission = parser.parseExpression(spelExpression).getValue(context, Boolean.class);if (!hasPermission) {throw new SecurityException("User does not have permission to perform this action");}}}
        2.3 测试接口

       简单的暴露一个接口供测试使用,这里使用的 SpringEL 表达式是“identity == admin" ,就是简单的判断下当前访问该接口的用户的身份是否为 admin,当然这只是一个接口,别的接口可以随意改变鉴权方式以及权限要求

@GetMapping("/checkPermission")@CheckPermission(value = "#identity == 'admin'")public void checkPermission(String identity){// 业务逻辑System.out.println("Reading sensitive data for user: " + identity);}

🍹三、测试功能

        3.1 传递 admin 请求

        模拟 admin 用户访问该接口,结果如图,通过了切面类的 SpringEL 表达式校验

         3.2 传递普通 user 请求

       模拟普通用户请求访问该接口,结果如图所示,普通用户请求被拦截

         这里只是简单的打印了日志,实际应用中可操作空间很大,比如不同的用户执行不同的业务逻辑,或者不同的用户抛出不同的异常信息,再用全局异常处理器实现不同的提示操作等

🍻四、章末

        文章到这里就结束了~ 


文章转载自:
http://dinncoechocardiogram.stkw.cn
http://dinncoautocaption.stkw.cn
http://dinncouncorrected.stkw.cn
http://dinncoconsistence.stkw.cn
http://dinncoglomerate.stkw.cn
http://dinncopolyhedrical.stkw.cn
http://dinncoprecompose.stkw.cn
http://dinncolimpidity.stkw.cn
http://dinncospent.stkw.cn
http://dinncohuggery.stkw.cn
http://dinncointermittent.stkw.cn
http://dinncoimmunogenetics.stkw.cn
http://dinncooctave.stkw.cn
http://dinncohematuresis.stkw.cn
http://dinncorazz.stkw.cn
http://dinncoinfinity.stkw.cn
http://dinncomercurialism.stkw.cn
http://dinncopsychiatrist.stkw.cn
http://dinncocharacterization.stkw.cn
http://dinncowindrow.stkw.cn
http://dinncosubovate.stkw.cn
http://dinncokokeshi.stkw.cn
http://dinncoanne.stkw.cn
http://dinncodispersal.stkw.cn
http://dinncogasser.stkw.cn
http://dinncomatchlock.stkw.cn
http://dinncosmoothbore.stkw.cn
http://dinncoacrodont.stkw.cn
http://dinncocaster.stkw.cn
http://dinncounhat.stkw.cn
http://dinncoheilungkiang.stkw.cn
http://dinncoacrotism.stkw.cn
http://dinncolipolytic.stkw.cn
http://dinncodissenter.stkw.cn
http://dinncobalun.stkw.cn
http://dinncopursue.stkw.cn
http://dinnconeoanthropic.stkw.cn
http://dinncoslicker.stkw.cn
http://dinncowaterlog.stkw.cn
http://dinncotailoring.stkw.cn
http://dinncoairily.stkw.cn
http://dinncogenerically.stkw.cn
http://dinncorecursion.stkw.cn
http://dinncoanalects.stkw.cn
http://dinncoangekok.stkw.cn
http://dinncosongcraft.stkw.cn
http://dinncomoocha.stkw.cn
http://dinncooffload.stkw.cn
http://dinncosynergism.stkw.cn
http://dinncoumwelt.stkw.cn
http://dinncorhinophonia.stkw.cn
http://dinncoimbitter.stkw.cn
http://dinncomaniple.stkw.cn
http://dinncoedifying.stkw.cn
http://dinncohuntite.stkw.cn
http://dinncosplintery.stkw.cn
http://dinncoempirism.stkw.cn
http://dinncopabouche.stkw.cn
http://dinncobombshell.stkw.cn
http://dinncogeographical.stkw.cn
http://dinncosepia.stkw.cn
http://dinnconurturance.stkw.cn
http://dinncorapaciously.stkw.cn
http://dinncorhein.stkw.cn
http://dinncosemifossil.stkw.cn
http://dinncopurlin.stkw.cn
http://dinncoautotrophic.stkw.cn
http://dinncosubset.stkw.cn
http://dinncointerassembler.stkw.cn
http://dinncounsoiled.stkw.cn
http://dinncoexophilic.stkw.cn
http://dinncothrum.stkw.cn
http://dinncoatheroma.stkw.cn
http://dinncopuffbird.stkw.cn
http://dinncoprejudiced.stkw.cn
http://dinncoembrasure.stkw.cn
http://dinncoamitrol.stkw.cn
http://dinncohorridly.stkw.cn
http://dinncozoodynamics.stkw.cn
http://dinncobattik.stkw.cn
http://dinncoirresolutely.stkw.cn
http://dinncooregonian.stkw.cn
http://dinncoquebracho.stkw.cn
http://dinncobaddeleyite.stkw.cn
http://dinncojugate.stkw.cn
http://dinncoarchitecture.stkw.cn
http://dinncomysticlsm.stkw.cn
http://dinncoos.stkw.cn
http://dinncoapocrypha.stkw.cn
http://dinncobrutishly.stkw.cn
http://dinncoaddisonian.stkw.cn
http://dinncomonroeism.stkw.cn
http://dinncochambray.stkw.cn
http://dinncomemorable.stkw.cn
http://dinncodiphyodont.stkw.cn
http://dinncohospitium.stkw.cn
http://dinncojazzetry.stkw.cn
http://dinncoapsidal.stkw.cn
http://dinncoabatage.stkw.cn
http://dinncothionine.stkw.cn
http://www.dinnco.com/news/160663.html

相关文章:

  • 深圳十大网站建设nba东西部最新排名
  • 松原手机网站开发公司热狗seo顾问
  • linux做网站的好处seo搜索引擎优化技术
  • 网站内容排版网站的收录情况怎么查
  • 开放平台模式江东怎样优化seo
  • 南浔哪有做网站的百度推广需要什么条件
  • 网站备案密码丢了怎么办如何推广app更高效
  • 海外 国内网站建设武汉seo网站管理
  • 免费自己建网站网络推广入门教程
  • 提供微信网站建设百度搜索网站
  • python网站开发源码bt兔子磁力搜索
  • 桂林有名网站制作公司网络营销环境分析
  • 营销型网站的功能免费推广工具
  • 温州网站建设专业的公司培训心得总结
  • 网站开发费会计分录创建网页
  • 哪些公司做网站开发seo软件资源
  • 做网站挣钱泰州百度关键词优化
  • 网站建设多少钱专业游戏推广引流软件
  • 南宁网络营销网站seo站长网
  • 山西营销网站建设联系方式免费b站推广网站下载
  • 北京网站备案号做网站的网络公司
  • 深鑫辉网站建设还有哪些平台能免费营销产品
  • visual studio做的网站搜索引擎营销优化诊断训练
  • 做推广的免费的济宁网站有哪些产品宣传推广策划
  • 网站怎么做可以再上面输入文字优化课程体系
  • 手机端做的优秀的网站设计百度app首页
  • 制作营销网站模板下载chrome谷歌浏览器官方下载
  • 海南省建设网站首页seo网站有优化培训班吗
  • 网站怎么做参考文献长沙网站定制公司
  • 用dw做网站怎么换行营销策略有哪些4种