aws-amplify / aws-amplify/amplify-codegen
Groups authorization not working as expected for GraphQL transformer v2 - Not Authorized
- Dominant language
- TypeScript
- Stars
- 59
- Forks
- 64
- PR merge metrics
- No merged PRs in 30d
Description
### Before opening, please confirm:
- [X] I have installed the latest version of the Amplify CLI (see above), and confirmed that the issue still persists.
- [X] I have [searched for duplicate or closed issues](https://github.com/aws-amplify/amplify-cli/issues?q=is%3Aissue+).
- [X] I have read the guide for [submitting bug reports](https://github.com/aws-amplify/amplify-cli/blob/master/CONTRIBUTING.md#bug-reports).
- [X] I have done my best to include a minimal, self-contained set of instructions for consistently reproducing the issue.
### How did you install the Amplify CLI?
npm
### If applicable, what version of Node.js are you using?
v16.13.2
### Amplify CLI Version
7.6.12
### What operating system are you using?
macos
### Did you make any manual changes to the cloud resources managed by Amplify? Please describe the changes made.
no
### Amplify Categories
auth, api
### Amplify Commands
Not applicable
### Describe the bug
Getting:
`Not Authorized to access listFoo on type Query`
When performing a list on the model
```
this.apiService.ListFoo();
```
### Expected behavior
Group authentication should work as documented
### Reproduction steps
1. auth rule for groups
2. cognito user with admin
3. try to access model data restricting to admin group
### GraphQL schema(s)
```graphql
# Put schemas below this line
type Foo
@model
@auth(rules: [
{ allow: groups, groups: ["admin"]},
{ allow: groups, groupsField: "groupsCanAccess", operations: [read] }
])
{
name: String!
groupsCanAccess: [String]
}
```
### Log output
```
# Put your logs below this line
error: Error: Uncaught (in promise): Object: {"data":{"listFoos":null},"errors":[{"path":["listFoos"],"data":null,"errorType":"Unauthorized","errorInfo":null,"locations":[{"line":2,"column":3,"sourceName":null}],"message":"Not Authorized to access listFoos on type Query"}]}
at qe (polyfills.js:1:150135)
at polyfills.js:1:149161
at c (main.js:1:251763)
at S.invoke (polyfills.js:1:140059)
at Object.onInvoke (main.js:1:147119)
at S.invoke (polyfills.js:1:139998)
at S.run (polyfills.js:1:135092)
at polyfills.js:1:150973
at S.invokeTask (polyfills.js:1:140745)
at Object.onInvokeTask (main.js:1:146929)
```
### Additional information
_No response_
Contributor guide
Assessment
This issue has not been assessed yet.