我可以在Quarkus静态地访问当前用户吗?
我需要以静态方式访问当前用户(以前由containerRequestFilter
),以避免在每种方法中的每种方法中@context SecurityContext
控制器。
我想实现一些目标,在春季,
SecurityContextHolder.getContext().getAuthentication();
除了在Quarkus中使用Spring Security之外,我是否会做任何方法?
I need to do access to the current user (previously set up by a ContainerRequestFilter
) in a static way, to avoid the passage of the @Context SecurityContext
in every method of every controller.
I want to achieve something that, in Spring, I would do with
SecurityContextHolder.getContext().getAuthentication();
Is there any way to do it, besides using Spring Security in Quarkus?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
解决方案是使用此依赖项
,然后您可以操纵
securityidentity
的实例“使其静态”}
@startup
在应用程序开始时实例化了BEAN(而不是懒惰) 。然后,您可以使用
userutilsservice.getCustomuser();
stally stat上访问主体。The solution is to use this dependency
Then you can manipulate the instance of
SecurityIdentity
to "make it static"}
@StartUp
does instantiate the bean on application start (instead of lazily).You can then access to the Principal statically using
UserUtilsService.getCustomUser();