无法在AWS预言触发中添加自定义范围

发布于 2025-01-20 04:53:22 字数 432 浏览 3 评论 0原文

我的 AWS Cognito 用户池具有一个允许我的应用程序客户端自定义范围,即仅限管理员。我有两种用户1。管理员组 2 中的用户。非管理员用户。对于我的 AWS API Gateway 路由之一,如果非管理员组的用户访问 API Url,我需要拒绝访问,基本上只允许属于管理员用户组的用户。

我可以通过使用此自定义范围在 API 网关路由上添加授权范围来实现此目的,然后当我在托管 UI 弹出窗口中请求授权令牌时手动添加范围。但在我的应用程序中,我不想手动添加此范围,而是想在生成令牌时添加此范围。我探索了预令牌生成触发器,但无法看到在其中覆盖或添加scope属性的方法?

问题是,有没有办法在预令牌生成触发器中添加/覆盖自定义范围?如果是的话怎么办?但如果没有办法,那么如何解决我的用例?

I have AWS Cognito user pool with one Allowed custom scopes for my app client i.e. admin-only. I have two kinds of users 1. Users in Admin Group 2. Non-Admins users. For my one of the AWS API Gateway Routes, I need to deny the access if user from non admin group is hitting the API Url, basically its allowed only for users which are part of Admin User group.

I can achieve it through adding an Authorization scope on API gateway route with this custom scope and then adding a scope manually when I request an Authorization token in Hosted UI popup. But in my app, I don't want to add this scope manually, rather want to add this scope when the token is generated. I explored Pre-Token Generation Trigger but not able to see the way to override or add scope attribute in it?

Question is, is there a way to add/override custom scope in pre-token generation trigger ? If yes then how ? But if there is no way, then how to solve my use case ?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

落叶缤纷 2025-01-27 04:53:22

您可以在响应中使用 ClaimsToAddOrOverride 属性,将令牌中返回的范围值替换为您想要的任何内容,但您似乎看不到 lambda 中的现有值,因此需要预先了解完整的值集

You can use the claimsToAddOrOverride attribute in the response to replace the scopes value returned in the token with anything you want, BUT you cannot see the existing values in the lambda it seems so would need to know the full set of values up front

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文