question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

@auth Directive to allow owner AND group

See original GitHub issue

** Which Category is your question related to? ** GraphQL Transform

** What AWS Services are you utilizing? ** AWS AppSync

** Provide additional details e.g. code snippets ** I read the GraphQL Transform doc but I must have missed something. How do I use the @auth directive to allow only the owner who is also in a group Member? So the owner can do all the queries and mutations but must belong to Member group. To put it in another way, If you belong to Member group but you are not the owner, you are not authorized to query or mutate.

type Project @model @auth(rules: [
    { allow: owner },
    { allow: groups group: ["X"] }
]) { ... }

The way I wrote above, I believe, grants owner OR Member group all the rights to every Project? So anyone that belongs to Member group can, for example, delete a Project that doesn’t belong to that person?

Thanks 👍

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:7 (1 by maintainers)

github_iconTop GitHub Comments

4reactions
rawadrifaicommented, Apr 23, 2019

How do you allow read/write for owner and read only for every other authenticated user?

2reactions
ghostcommented, Jul 18, 2019

@mikeparisstuff any answer for @rawadrifai’s question? Consider a common use case, where there are private and public user profiles. The owner of the profile should have full access where the other authenticated users should be able to read a subset of user fields. Ideally there should be something like,

@auth(rules: [
        { allow: owner},
        { allow: everyone, operations: [read], fields: []}
])
Read more comments on GitHub >

github_iconTop Results From Across the Web

API (GraphQL) - Setup authorization rules - AWS Amplify Docs
Static group authorization allows you to protect @model types by restricting access to a known set of groups. For example, you can allow...
Read more >
AWS GraphQL @auth Directive For Beginners | Geek Culture
This will allow only the owner to read, update, delete, but also allow anyone in the editors group to update and read, but...
Read more >
6 GraphQL Authorization Schemas for AWS Amplify - IOD
Because the auth directive parameter accepts a rules array, it can be modeled with multiple “owner” and “group” rules. The GraphQL schema looks ......
Read more >
Authentication and authorization - Apollo GraphQL Docs
Another way to go about authorization is via GraphQL Schema Directives. A directive is an identifier preceded by a @ character, optionally followed...
Read more >
GraphQL Directive Permissions — Authorization Made Easy
Directive permissions are a declarative way of implementing authorization rules in GraphQL servers. In this article, our guest author Dennis ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found