无法在AWS预言触发中添加自定义范围
我的 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 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在响应中使用 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