Skip to content

Instantly share code, notes, and snippets.

@qdx
Created October 22, 2021 07:24
Show Gist options
  • Save qdx/a0f97c5018a6b4a1790c05477b3522ae to your computer and use it in GitHub Desktop.
Save qdx/a0f97c5018a6b4a1790c05477b3522ae to your computer and use it in GitHub Desktop.
Tricky things when importing a lot of users into proxy

Before we have the performance issue of policies fixed, importing large amount of users requires the developer to implement a special import process. Basically the idea is to skip the policy syncs while importing, and trigger the policy sync only once after the import is finished.

  1. If you are using Create a person or Create or update a person endpoint for user imports, please switch to Create multiple persons endpoint instead first.
  2. To skip policy sync for an import, add skipSyncPolicies=true in the query string while calling Create multiple persons endpoint.
  3. To trigger the policy sync after import is done, we need to get and then patch all policies.
    1. Retrieve all policies by calling Retrieve all policies endpoint. A policy is a permission created on Proxy Dashboard. You might need to use proper limit and page query values if you have a lot of policies.

    2. For each policy, call the Update a policy endpoint, with body including the same document field you got from Retrieve all policies endpoint. See example below. Note: We simplified the process by blindly patching all policies. If you're able to detect which policies are touched (by checking the groups of persons & policies), that would be optimal.

      PATCH https://api.proxy.com/manage/policies/723fa0a2-db30-4e6f-80ab-a85fddb190d7?orgId=848e74c5-712e-4402-b641-cbb862355bb4&siteId=ee334d52-1bad-41fe-a8f3-fb0163831613
      
      {
        "document": {
          "Version": "2019-05-24",
          "Statement": {
            "Effect": "Allow",
            "Action": [
              "unlock"
            ],
            "Grant": [
              "proxy:person-group:2a116c91-7b39-488e-9c16-0eb5dc5fb6e4"
            ],
            "Resource": [
              "proxy:door:beee2c58-747c-42d2-9e7f-6c49a0fa667c",
              "proxy:door:404e91e4-246e-4b39-9d00-9a99efcb9324",
              "proxy:door:56984ebb-4cb4-48ec-a983-ea2183e3f37c"
            ],
            "Ruleset": {
              "schedule": []
            }
          }
        }
      }
      
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment