-
Notifications
You must be signed in to change notification settings - Fork 505
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
关于在realm进行登入时抛出异常的问题 #6
Comments
使用 |
尝试还是无法被ExceptionController所捕获呢? |
你参考下我的吧 |
添加了的,我试了一下你的demo,即使我乱输入一个token,是提示Unauthorized。按理来说应该是在MyRealm中跑token invalid异常。 |
如果在JWTFilter中的isAccessAllowed方法里不catch, 还是不会走ExceptionController 。 |
我明天看看,最近比较忙。实在不行可以先像我一样catch下。 |
看了下,的确没有什么好的办法,因为JWTFilter执行的时候SpringBoot的Controller都还没启动,所以无法捕捉异常,感觉还是URL redirect才是最好的办法了。 |
是的,所以我现在将异常捕捉之后,把异常信息一起带到了401里面,然后通过401接口返回去 |
好吧 |
在JWTFilter中有如下方法
此时Header中带有Authorization,那么将会去MyRealm中进行用户验证。
如果Authorization传过来的token是错误的,就会抛出异常。但是再MyRealm.java 中的doGetAuthenticationInfo中抛出的异常,无法被ExceptionController所捕获,就导致返回的数据结构不统一了。
请问有解决办法吗?
The text was updated successfully, but these errors were encountered: