Closed BBopanna closed 2 years ago
@iartemiev @ErikCH - Can you please comment/take a look ?
Hi @BBopanna - This a top requested feature by our customers, and it is currently tracked here. Closing this as a duplicate.
@abdallahshaban557 - Please do not close this ticket as duplicate of https://github.com/aws-amplify/amplify-category-api/issues/452 opened in 2018!!!!!. While we - your customers sit and wait for another 5 years for you jokers to implement a basic requirement - we need to implement an alternative solution and hence this ticket.
Instead of helping out with the questions, the reckless and callous response of closing as duplicate reflects very poorly on AWS and teams working on it.
We spent good time to document the issue and possible approach for the world to discuss and come to a solution on this platform - please reopen and allow for the possibility of discussion.
@BBopanna - we are trying to consolidate all potential approaches and customer requests to allow us to have a single view of all issues related to Multi-tenancy support. The details in this ticket have been shared with the team working on enabling this feature set - I can see you have left a comment on the issue I mentioned, the discussion can be continued on that including questions on the approach you are pursuing.
@abdallahshaban557 - so you are asking me to copy-paste this exact content in another ticket - very smart! why dont average humans think like this !!! Oh yea, average human is not so smart i am assuming per your advice - thank you for your kindness anyway.
Before opening, please confirm:
JavaScript Framework
React
Amplify APIs
Authentication, GraphQL API
Amplify Categories
auth, storage, api
Environment information
Describe the bug
Requirement - Implement multi tenancy in a react app backed by amplify ( Cognito + Appsync + S3)
Use case and our idea with gaps -
Use case -
Our attempted idea with gaps - which need help with OR a better design advise please :
Graphql models :
`============ type Post @model @auth(rules: [ { allow: groups, groupsField: "adminGroup" , operations: [read, create, update, delete], provider: userPools} { allow: groups, groupsField: "managerGroup" , operations: [read, create, update], provider: userPools} { allow: groups, groupsField: "userGroup" , operations: [read], provider: userPools} ]) { id: ID!
title: String
adminGroup: String @auth(rules: [{ allow: groups, groupsField: "adminGroup"}])
managerGroup: String @auth(rules: [{ allow: groups, groupsField: "adminGroup"},{ allow: groups, groupsField: "managerGroup"}])
userGroup: String }
type AuthorizationGroups @model @auth(rules: [ { allow: private, operations: [read, create, update, delete], provider: iam } ]) { id: ID!
tentantId: String!
adminGroupId: String!
managerGroupId: String!
userGroupId: String! }
`
Flow :
Admin will signup with the app
We call post signup lambda hook to a. Add tenantId to user in cognito - uuid generated and put into cognito custom attribute - tenantId b. Put an entry to AuthorizationGroups table with tentantId generated above from #a and uuids generated for adminGroupId, managerGroupId, userGroupId - this entity can only be operated by lambda hence the rule allow private. We do not want any direct user meddling or attempting to hack
Admin/Manager can create/updatePost record - during which we want to read the values for adminGroupId, managerGroupId and userGroupId from AuthorizationGroups entity for the tenantId of the belonging user, from cognito custom attribute- tenantId, and set these values before persisting - How can we achieve this ? Do not want to do it in client code - can be hacked is what we worry. Next lambda - How can the request be intercepted and these values set ? Unless all graphql APIs be explicitly routed to lambda which updates these values and then calls underLying AppSync APIs - too cumbersome and lot of hand written code ? Deal with resolver - again touch all resolvers - very painful? Is there a better approach - a lambda hook that gets called for all AppSync calls where we set these values ?
Admin/Manager/User should be able to read the data, so again we need to use similar logic as from # 3 to proceed
How do we extend these for storage and retrieval of multimedia - Images, Videos from S3 ?
This - https://aws.amazon.com/blogs/mobile/appsync-lambda-auth/ seems like what we want but not able to put everything together for our use case.
Here is 2018 request for multi tenancy - https://github.com/aws-amplify/amplify-category-api/issues/449 which is not considered yet.
Expected behavior
Possible options to implement multi tenancy.
Reproduction steps
NA
Code Snippet
Log output
aws-exports.js
No response
Manual configuration
No response
Additional configuration
No response
Mobile Device
No response
Mobile Operating System
No response
Mobile Browser
No response
Mobile Browser Version
No response
Additional information and screenshots
No response