LD4P / sinopia_acl

node.js based code to interact with WebACL data on sinopia server
Apache License 2.0
0 stars 0 forks source link

app is not successfully updating admin user list on stage and prod #83

Open jmartin-sul opened 5 years ago

jmartin-sul commented 5 years ago

spawned from LD4P/sinopia#224, which has lots more background and context.

currently, my very strong suspicion is that the user getting the cognito token and doing the update is not itself actually an admin user in the root ACL. e.g., when i queried the ACL on stage to see who has control privileges, the webID for sinopia-devs_client-tester was not in the list. that user is also absent from the list of admin users in the config file, despite being specified as the cognito admin user: https://github.com/LD4P/sinopia_acl/blob/7ac2681b14ad76b2c10ba67bcae2fd3a2793aeac/config/default.js#L8-L22

however, when i went to try and add a new admin user to the root ACL on stage, executing bin/migrate from my laptop per the README, using my user (suntzu, whose webID does have control privs in the root ACL), things went smoothly for the group container creation, and then failed out on the admin user addition portion (i.e. the part we're trying to debug). the errors i get are along the lines of the following, for each defined admin user:

ERROR: problem getting webid for suntzu: { AccessDeniedException: User: arn:aws:iam::390882271260:user/suntzu is not authorized to perform: cognito-idp:AdminGetUser on resource: arn:aws:cognito-idp:us-west-2:390882271260:userpool/us-west-2_ilMQW0M0R with an explicit deny
    at Request.extractError (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/protocol/json.js:51:27)
    at Request.callListeners (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
  message: 'User: arn:aws:iam::390882271260:user/suntzu is not authorized to perform: cognito-idp:AdminGetUser on resource: arn:aws:cognito-idp:us-west-2:390882271260:userpool/us-west-2_ilMQW0M0R with an explicit deny',
  code: 'AccessDeniedException',
  time: 2019-08-12T17:20:46.437Z,
  requestId: '8961fbaa-cc6d-4e7e-b2ba-655cebe5df0f',
  statusCode: 400,
  retryable: false,
  retryDelay: 4.8825290947741795 }
(node:78788) UnhandledPromiseRejectionWarning: ERROR: problem getting webid for suntzu: { AccessDeniedException: User: arn:aws:iam::390882271260:user/suntzu is not authorized to perform: cognito-idp:AdminGetUser on resource: arn:aws:cognito-idp:us-west-2:390882271260:userpool/us-west-2_ilMQW0M0R with an explicit deny
    at Request.extractError (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/protocol/json.js:51:27)
    at Request.callListeners (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/sequential_executor.js:106:20)
    at Request.emit (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/sequential_executor.js:78:10)
    at Request.emit (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/request.js:683:14)
    at Request.transition (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/request.js:22:10)
    at AcceptorStateMachine.runTo (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/state_machine.js:14:12)
    at /Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/state_machine.js:26:10
    at Request.<anonymous> (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/request.js:38:9)
    at Request.<anonymous> (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/request.js:685:12)
    at Request.callListeners (/Users/suntzu/software_dev_projects/sinopia_acl/node_modules/aws-sdk/lib/sequential_executor.js:116:18)
  message: 'User: arn:aws:iam::390882271260:user/suntzu is not authorized to perform: cognito-idp:AdminGetUser on resource: arn:aws:cognito-idp:us-west-2:390882271260:userpool/us-west-2_ilMQW0M0R with an explicit deny',
  code: 'AccessDeniedException',
  time: 2019-08-12T17:20:46.437Z,
  requestId: '8961fbaa-cc6d-4e7e-b2ba-655cebe5df0f',
  statusCode: 400,
  retryable: false,
  retryDelay: 4.8825290947741795 }
(node:78788) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1)
(node:78788) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

i suspect that this may be unique to my laptop setup, or may be an issue with the way i'm invoking bin/migrate. the command i ran was:

TRELLIS_BASE_URL='https://trellis.stage.sinopia.io/' COGNITO_USER_POOL_ID='us-west-2_ilMQW0M0R' COGNITO_CLIENT_ID='23l30pbu74pusgh7cmtufb8d05' COGNITO_ADMIN_USER='suntzu' COGNITO_ADMIN_PASSWORD='<not the actual password>' AWS_PROFILE=staging bin/migrate

though... looking at the terraform code, i am curious as to how the AWS creds are provisioned on the sinopia_acl container in AWS-land. based on the prior issues we were seeing in the ticket from which this was spawned, it seems possible that user lookup was never actually being exercised yet in AWS-land.

i also took the liberty of creating a new ACL admin specific user (manually registered the user via cognito signup on dev, stage, and prod). i have a draft PR up in our terraform repo to switch to that user, and will put up a corresponding sinopia_acl draft PR shortly. i created this user both to keep from possible simultaneous login by an account that we already share for integration tests run locally and in CI, as well as to keep user/password re-use to a minimum, esp since this is a somewhat more sensitive use case than integration testing. the sinopia_acl PR will also fix things so that the default sinopia_acl admin user for making changes is also in the default list of admin users to be put in the ACL when bin/migrate is run.

since we're pausing sinopia work for a few weeks to do some maintenance, i'm leaving these notes with the intent of picking the work back up when we start back on sinopia work in general. we don't anticipate adding admins very frequently, and can do so manually when needed (either by figuring out how to run bin/migrate as has successfully been done in the past, or by manual curl POSTs to trellis with a valid cognito token for a current admin user).

i'll assign myself for now, since i've been investigating this off and on for the last few weeks. but since @mjgiarlo and @ndushay wrote this code, and have more experience with this code base, i will likely try to pair with one or both of them when i get back to this.

jmartin-sul commented 5 years ago

per the issue this was spawned from, these things will need to be confirmed to consider the issue closed:

jmartin-sul commented 5 years ago

there are useful ACL queries and update sql statements in comments on the old ticket.