-
Notifications
You must be signed in to change notification settings - Fork 4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[aws-cdk/appsync] - aws_auth directive ignored #8844
Comments
Hi Tom thanks for submitting an issue! I reproduced what were showing me and I got mine to work by making the |
Thank you for getting back to me @BryanPan342, I really appreciate it. I'm not sure I fully understand, I created a group titled "Admins", to match what I specified in my schema, a user not in that group could still query data that was seemingly restricted from doing that (this is my bug). If I understand what you're saying correctly, you have created a new role that grants admin, and attached this to the "Admins" group, at which point you have requested some data and been given it, have you tried requesting from a user who is not in that group? Thanks Bryan. |
Hm this is interesting. So the policy statement should look something like this. {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Action": [
"appsync:GraphQL"
],
"Resource": [
"arn:aws:appsync:[REGION]:[ACCOUNT_ID]:apis/[GRAPHQL_ID]/types/Mutation/fields/doMutation"
]
}
]
} where the resource section are the ARNs for the resources you want to allow access to for the policy you are creating. Something to note as well is if you are doing a Mutation, then make sure to also give access to the types in the schema directive: type superSecret @aws_auth(cognito_groups: ["Admins"]) {
...
}
type Mutation {
addSuperSecret (...): ...
@aws_auth(cognito_groups: ["Admins"])
} I know this works for I'm looking into that condition you just said and will respond by tomorrow. If you need an Admins for backend tasks I suggest using Also have you looked at this part of the documentation?
|
From what I can see right now, I think this is more of a documentation problem than a bug so changing the label for now. |
Thanks for your investigation @BryanPan342 , did you come to a conclusion? Is the outcome that aws_auth is not supported by schemas deployed via CDK? |
If you use additional authorization then you must use the I think what might have happened @tombuckley91 was that the bug from the Rule of thumb:
|
I'm closing this issue for now but if there is something I missed, please reopen it or continue adding to the discussion. |
It would be expected that the above code would restrict the getCustomers query to users who exist in the Admins group. This is an example of the starter code made available on the AppSync CDK page.
Reproduction Steps
Copy the demo code from AppSync CDK, add the above directive to the included graphql.schema, deploy your changes, make a query from a user that is not the specified group, expect to have information returned.
Error Log
Environment
Other
This is 🐛 Bug Report
The text was updated successfully, but these errors were encountered: