Skip to content

Instantly share code, notes, and snippets.

@sandrinodimattia
Created May 5, 2016 09:42
Show Gist options
  • Save sandrinodimattia/13d625dda7617b2860077ba208d13e61 to your computer and use it in GitHub Desktop.
Save sandrinodimattia/13d625dda7617b2860077ba208d13e61 to your computer and use it in GitHub Desktop.
Auth0 Authorization Extension API

Create a group

POST https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups

{
  "name": "My group",
  "description": "My group description"
}

Response:

{
  "name": "My group",
  "description": "My group description",
  "_id": "751e8a9f-3d69-4151-b38b-524048038525"
}

Update a group

PUT https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID

{
  "name": "My new group name",
  "description": "My new group description"
}

Response:

{
  "_id": "751e8a9f-3d69-4151-b38b-524048038525",
  "name": "My new group name",
  "description": "My new group description"
}

Delete a group

DELETE https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID

Get a group

GET https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID

Response:

{
  "_id": "cd4dc2d0-fda0-49d9-a883-ec25b8da2b0f",
  "name": "Fabrikam",
  "description": "The company"
}

Get the direct members of a group

GET https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID/members

Response:

[
  {
    "email": "[email protected]",
    "email_verified": false,
    "updated_at": "2016-03-25T05:12:26.031Z",
    "user_id": "auth0|1111111111111",
    "name": "[email protected]",
    "nickname": "some-user",
    "identities": [
      {
        "user_id": "1111111111111",
        "provider": "auth0",
        "connection": "Username-Password-Authentication",
        "isSocial": false
      }
    ],
    "created_at": "2016-03-25T05:12:25.117Z",
    "last_ip": "1.1.1.1",
    "last_login": "2016-03-25T05:12:26.030Z",
    "logins_count": 1
  },
  {
    "email": "[email protected]",
    "name": "John Fabrikam",
    "given_name": "John",
    "email_verified": true,
    "updated_at": "2016-03-21T09:43:12.208Z",
    "picture": "https://s.gravatar.com/avatar/5426f6b9d63ad92d60e6fe9fdf83aa21?s=480&r=pg&d=https%3A%2F%2Fcdn.auth0.com%2Favatars%2Fjf.png",
    "user_id": "adfs|[email protected]",
    "nickname": "john",
    "identities": [
      {
        "user_id": "[email protected]",
        "provider": "adfs",
        "connection": "test-adfs",
        "isSocial": false
      }
    ],
    "created_at": "2016-02-15T18:16:13.822Z",
    "blocked": false,
    "last_login": "2016-02-24T10:50:43.679Z",
    "logins_count": 11
  }
]

Get the mappings for a group

GET https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID/mappings

Response:

[
  {
    "_id": "bc7fe950-7d9f-4a7e-9302-0e9603fec270",
    "groupName": "Domain Users",
    "connectionName": "fabrikam-ad (ad)"
  }
]

Get the nested groups for a group (direct "children")

GET https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID/nested

Response:

[
  {
    "_id": "f58b701c-14a1-411a-a7a0-e1aedcfae2b1",
    "name": "Fabrikam IT",
    "description": "Supporting IT services",
    "members": [
      "google-oauth2|1111111111",
      "google-oauth2|2222222222"
    ]
  }
]

Add a nested group to a group

PATCH https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID/nested

[
  "433c2877-eeb5-4357-9ca0-92289c06e172"
]

Delete a nested group from a group

DELETE https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID/nested

{ groupId: "433c2877-eeb5-4357-9ca0-92289c06e172" }

Get all members of a group, including members as a result of nested groups.

GET https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID/members/nested

Response:

[
  {
    "user": {
      "user_id": "google-oauth2|1333929933",
      "name": "User Abc",
      "nickname": "abc",
      "email": "[email protected]"
    },
    "group": {
      "_id": "f58b701c-14a1-411a-a7a0-e1aedcfae2b1",
      "name": "Fabrikam IT",
      "description": "Supporting IT services"
    }
  },
  {
    "user": {
      "user_id": "adfs|[email protected]",
      "name": "John Fabrikam",
      "nickname": "john",
      "email": "[email protected]"
    },
    "group": {
      "_id": "cd4dc2d0-fda0-49d9-a883-ec25b8da2b0f",
      "name": "Fabrikam",
      "description": "The company"
    }
  }
]

Note: The response contains the group where the user originates from (to know in which nested group the user was found).

Add users to a group

PATCH https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID/members

[
  "ad|fabrikam-ad|ae619853-9886-42db-966b-e88961671412",
  "auth0|5632501f468f0f1756f4cab0"
]

Remove a user from a group

DELETE https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups/GROUP_ID/members

{
  "userId": "adfs|[email protected]"
}

List all groups

GET https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/groups

Response:

[
  {
    "_id": "cd4dc2d0-fda0-49d9-a883-ec25b8da2b0f",
    "name": "Fabrikam",
    "description": "The company",
    "members": [
      "auth0|56f4c8b9273a70fe6823ef65",
      "adfs|[email protected]"
    ],
    "nested": [
      "f58b701c-14a1-411a-a7a0-e1aedcfae2b1"
    ],
    "mappings": [
      {
        "_id": "bc7fe950-7d9f-4a7e-9302-0e9603fec270",
        "groupName": "Domain Users",
        "connectionName": "fabrikam-ad"
      }
    ]
  },
  {
    "_id": "f58b701c-14a1-411a-a7a0-e1aedcfae2b1",
    "name": "Fabrikam IT",
    "description": "Supporting IT services",
    "members": [
      "google-oauth2|109051264933766380611",
      "google-oauth2|100155328118194762201"
    ],
    "mappings": []
  }
]

Note: The response only contains the direct members of the group. Members that are the result of nested groups or group mappings will not show here.

Get the groups for a user

GET https://sandbox.it.auth0.com/api/run/YOUR_ACCCOUNT/YOUR_EXTENSION/api/users/USER_ID/groups

Response:

[
  {
    "_id": "cd4dc2d0-fda0-49d9-a883-ec25b8da2b0f",
    "name": "Fabrikam",
    "description": "The company"
  }
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment