CirclesUBI / circles-api-legacy

User and organization profile service
GNU Affero General Public License v3.0
4 stars 0 forks source link

Set up permissions #19

Closed ana0 closed 5 years ago

ana0 commented 5 years ago

Get some sense of access control in the api

ana0 commented 5 years ago

Looking at: https://aws.amazon.com/blogs/mobile/building-fine-grained-authorization-using-amazon-cognito-user-pools-groups/

edzillion commented 5 years ago

OK I figured out one way to add users to group:

You can set triggers on a Cognito Pool, so I set up one on user confirmation called userConfirm which takes the user event from the Auth.confirmSignUp() on the frontend and uses the deets to add the user to Cognito. Tested and working with the circles-remember-phone-test cognito pool:

    var params = {
            GroupName: 'circles-basic-user-group',
            UserPoolId: event.userPoolId,
            Username: event.userName
        };

        return cognitoISP.adminAddUserToGroup(params, (err,data) => {
            return data;
        });
edzillion commented 5 years ago

After redesiging my login flow with Ashoka's help - moving to the redux-saga paradigm - the lamda function is no longer working:

{code: "UserLambdaValidationException", name: "UserLambdaValidationException", message: "PostConfirmation failed with error Converting circular structure to JSON."}
code: "UserLambdaValidationException"
message: "PostConfirmation failed with error Converting circular structure to JSON."
name: "UserLambdaValidationException"

This SO Q seems to be talking about the same thing, but I am not sure what he means by 'data structure':

https://stackoverflow.com/questions/49417859/amazon-cognito-confirmpassword-fails-with-typeerror-converting-circular-struct

I am going to disable it for the moment, and come back as and when :/

edzillion commented 5 years ago

Ok I fixed it. And set up CI/CD in the PR here: https://github.com/CirclesUBI/infrastructure-provisioning/pull/20

edzillion commented 5 years ago

Can we close this and open a more specific one if we need @ana0 ?

ana0 commented 5 years ago

Closing because done