-
Notifications
You must be signed in to change notification settings - Fork 201
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
perf: 无权限提示信息带上用户名 #784
Comments
该异常主要是用户在操作鉴权时,没有相应的操作权限,通过PermissionDeniedException对象抛出的异常,主要想到两种处理方式 方案1PermissionDeniedException类中增加一个带有errorParams参数的构造方法,在需要抛出异常地方把username传进来。该异常用到的地方很多,所以改动很大,也不利于后续维护。 方案2从服务请求来分析,来自三个方面,web调用、esb调用、服务内部调用,需要鉴权的是web调用和esb调用,这两类调用中都有统一的异常Advice处理类,可以在其处理统一权限异常逻辑中获取到username信息并添加到响应对象。 web调用WebExceptionControllerAdvice#handlePermissionDeniedException() esb调用EsbExceptionControllerAdvice#handlePermissionDeniedException() i18n资源文件对权限不足的错误码添加username通配符,如: |
通过errorParams参数传递的话,还是需要在每个抛出异常的地方传进去,改动还是很大。 |
JobCommonInterceptor#addUsername(request)有把用户放到threadlocal中,每个web/esb请求都会执行到吗,能否直接拿出来用? |
设计上是都会执行到的,具体会不会可以分析下代码,也可以实践验证下 |
No description provided.
The text was updated successfully, but these errors were encountered: