admin管理员组文章数量:1125988
I have an api that exposes activities, let's say I have an endpoint
GET /users/123/activities
that is meant to return all activities that the user have joined.
I want to authorize only the owner of this particular resource to access it. For this purpose I map the subject id from the oidc to the user model in my service.
For now I came up with this solution in the controller/resource layer.
if (userService.isLoggedInUserTheOwner(id, identity.getPrincipal().getName())) {
return Response.status(403).build();
}
I wonder if there are other way of achieving this, I tried making custom policy but injecting a service to it resulted in a server error:
You have attempted to perform a blocking operation on a IO thread.
Is there a way to create some custom annotation to handle this logic?
I will be using this authorization all around and I don't want to repeat this boilerplate everytime.
本文标签:
版权声明:本文标题:authorization - Any alternative approaches to authorize acces to an endpoint based on bearer token subject - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736664870a1946608.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论