我们经常发布文档更新,此页面的翻译可能仍在进行中。有关最新信息,请访问英文文档。如果此页面上的翻译有问题,请告诉我们

SCIM

本文内容

Did this doc help you?

组织的 SCIM 预配

SCIM API 由 SCIM 启用的身份提供程序 (IdP) 用来自动预配 GitHub 组织成员身份。 GitHub API 基于SCIM 标准的 2.0 版本。 IdP 应使用的 GitHub SCIM 端点是:https://api.github.com/scim/v2/organisation/{org}/

注:SCIM API 仅适用于 GitHub Enterprise Cloud 上启用了 SAML SSO 的组织。 有关 SCIM 的更多信息,请参阅“关于 SCIM”。

向 SCIM API 验证调用

您必须验证为 GitHub 组织的所有者才可使用其 SCIM API。 API 预期 OAuth 2.0 Bearer 令牌包含在授权标头中。 您也可以使用个人访问令牌,但必须先授权它与您的 SAML SSO 组织一起使用

SAML 和 SCIM 数据的映射

SAML IdP 和 SCIM 客户端必须对每个用户使用匹配的 NameIDuserName 值。 这允许通过 SAML 进行身份验证的用户链接到其预配的 SCIM 标识。

支持的 SCIM 用户属性

名称类型描述
userName字符串用户的用户名。
name.givenName字符串用户的名字
name.lastName字符串用户的姓氏。
emails数组用户电子邮件列表。
externalId字符串此标识符由 SAML 提供程序生成,并且被 SAML 提供程序用作唯一 ID 来匹配 GitHub 用户。 您可以在 SAML 提供程序上查找用户的 externalID,或者使用 List SCIM 预配的身份端点并过滤其他已知的属性,如用户的 GitHub 用户名或电子邮件地址。
id字符串GitHub SCIM 端点生成的标识符。
active布尔值用于表示身份是处于活动状态 (true) 还是应解除预配 (false)。

注:SCIM API 的端点 URL 区分大小写。 例如,Users 端点中的第一个字母必须大写:

GET /scim/v2/organizations/{org}/Users/{scim_user_id}

List SCIM provisioned identities

Retrieves a paginated list of all provisioned organization members, including pending invitations. If you provide the filter parameter, the resources for all matching provisions members are returned.

When a user with a SAML-provisioned external identity leaves (or is removed from) an organization, the account's metadata is immediately removed. However, the returned list of user accounts might not always match the organization or enterprise member list you see on GitHub. This can happen in certain cases where an external identity associated with an organization will not match an organization member:

  • When a user with a SCIM-provisioned external identity is removed from an organization, the account's metadata is preserved to allow the user to re-join the organization in the future.
  • When inviting a user to join an organization, you can expect to see their external identity in the results before they accept the invitation, or if the invitation is cancelled (or never accepted).
  • When a user is invited over SCIM, an external identity is created that matches with the invitee's email address. However, this identity is only linked to a user account when the user accepts the invitation by going through SAML SSO.

The returned list of external identities can include an entry for a null user. These are unlinked SAML identities that are created when a user goes through the following Single Sign-On (SSO) process but does not sign in to their GitHub account after completing SSO:

  1. The user is granted access by the IdP and is not a member of the GitHub organization.

  2. The user attempts to access the GitHub organization and initiates the SAML SSO process, and is not currently signed in to their GitHub account.

  3. After successfully authenticating with the SAML SSO IdP, the null external identity entry is created and the user is prompted to sign in to their GitHub account:

    • If the user signs in, their GitHub account is linked to this entry.
    • If the user does not sign in (or does not create a new account when prompted), they are not added to the GitHub organization, and the external identity null entry remains in place.
get /scim/v2/organizations/{org}/Users

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended

org string path
startIndex integer query

Used for pagination: the index of the first result to return.

count integer query

Used for pagination: the number of results to return.

filter string query

Filters results using the equals query parameter operator (eq). You can filter results that are equal to id, userName, emails, and external_id. For example, to search for an identity with the userName Octocat, you would use this query:

?filter=userName%20eq%20\"Octocat\".

To filter results for for the identity with the email octocat@github.com, you would use this query:

?filter=emails%20eq%20\"octocat@github.com\".

代码示例

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/scim/v2/organizations/ORG/Users
JavaScript (@octokit/core.js)
await octokit.request('GET /scim/v2/organizations/{org}/Users', {
  org: 'org'
})

Response with filter

Status: 200 OK
{
  "schemas": [
    "urn:ietf:params:scim:api:messages:2.0:ListResponse"
  ],
  "totalResults": 1,
  "itemsPerPage": 1,
  "startIndex": 1,
  "Resources": [
    {
      "schemas": [
        "urn:ietf:params:scim:schemas:core:2.0:User"
      ],
      "id": "5fc0c238-1112-11e8-8e45-920c87bdbd75",
      "externalId": "00u1dhhb1fkIGP7RL1d8",
      "userName": "octocat@github.com",
      "name": {
        "givenName": "Mona",
        "familyName": "Octocat"
      },
      "emails": [
        {
          "value": "octocat@github.com",
          "primary": true,
          "type": "work"
        }
      ],
      "active": true,
      "meta": {
        "resourceType": "User",
        "created": "2018-02-13T15:05:24.000-08:00",
        "lastModified": "2018-02-13T15:05:55.000-08:00",
        "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/5fc0c238-1112-11e8-8e45-920c87bdbd75"
      }
    }
  ]
}

Notes


Provision and invite a SCIM user

Provision organization membership for a user, and send an activation email to the email address.

post /scim/v2/organizations/{org}/Users

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended

org string path
schemas array of strings body

Required. The SCIM schema URIs.

userName string body

Required. The username for the user.

name object body

Required. undefined

Properties of the name object

givenName (string)

Required. The first name of the user.

familyName (string)

Required. The last name of the user.

emails array of objects body

Required. List of user emails.

Properties of the emails items

value (string)

Required. The email address.

type (string)

Required. The type of email address.

primary (boolean)

Required. Whether this email address is the primary address.

代码示例

Shell
curl \
  -X POST \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/scim/v2/organizations/ORG/Users \
  -d '{"schemas":["schemas"],"userName":"userName","name":{"givenName":"givenName","familyName":"familyName"},"emails":["octocat@github.com"]}'
JavaScript (@octokit/core.js)
await octokit.request('POST /scim/v2/organizations/{org}/Users', {
  org: 'org',
  schemas: [
    'schemas'
  ],
  userName: 'userName',
  name: {
    givenName: 'givenName',
    familyName: 'familyName'
  },
  emails: [
    'octocat@github.com'
  ]
})

Default response

Status: 201 Created
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User"
  ],
  "id": "edefdfedf-050c-11e7-8d32",
  "externalId": "a7d0f98382",
  "userName": "mona.octocat@okta.example.com",
  "name": {
    "givenName": "Mona",
    "familyName": "Octocat"
  },
  "emails": [
    {
      "value": "mona.octocat@okta.example.com",
      "type": "work",
      "primary": true
    }
  ],
  "active": true,
  "meta": {
    "resourceType": "User",
    "created": "2017-03-09T16:11:13-05:00",
    "lastModified": "2017-03-09T16:11:13-05:00",
    "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32"
  }
}

Notes


get /scim/v2/organizations/{org}/Users/{scim_user_id}

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended

org string path
scim_user_id string path

Identifier generated by the GitHub SCIM endpoint.

代码示例

Shell
curl \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/scim/v2/organizations/ORG/Users/SCIM_USER_ID
JavaScript (@octokit/core.js)
await octokit.request('GET /scim/v2/organizations/{org}/Users/{scim_user_id}', {
  org: 'org',
  scim_user_id: 'scim_user_id'
})

Default response

Status: 200 OK
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User"
  ],
  "id": "edefdfedf-050c-11e7-8d32",
  "externalId": "a7d0f98382",
  "userName": "mona.octocat@okta.example.com",
  "name": {
    "givenName": "Mona",
    "familyName": "Octocat"
  },
  "emails": [
    {
      "value": "mona.octocat@okta.example.com",
      "type": "work",
      "primary": true
    }
  ],
  "active": true,
  "meta": {
    "resourceType": "User",
    "created": "2017-03-09T16:11:13-05:00",
    "lastModified": "2017-03-09T16:11:13-05:00",
    "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32"
  }
}

Notes


Set SCIM information for a provisioned user

Replaces an existing provisioned user's information. You must provide all the information required for the user as if you were provisioning them for the first time. Any existing user information that you don't provide will be removed. If you want to only update a specific attribute, use the Update an attribute for a SCIM user endpoint instead.

You must at least provide the required values for the user: userName, name, and emails.

Warning: Setting active: false removes the user from the organization, deletes the external identity, and deletes the associated {scim_user_id}.

put /scim/v2/organizations/{org}/Users/{scim_user_id}

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended

org string path
scim_user_id string path

Identifier generated by the GitHub SCIM endpoint.

schemas array of strings body

Required. The SCIM schema URIs.

userName string body

Required. The username for the user.

name object body

Required. undefined

Properties of the name object

givenName (string)

Required. The first name of the user.

familyName (string)

Required. The last name of the user.

emails array of objects body

Required. List of user emails.

Properties of the emails items

value (string)

Required. The email address.

type (string)

Required. The type of email address.

primary (boolean)

Required. Whether this email address is the primary address.

代码示例

Shell
curl \
  -X PUT \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/scim/v2/organizations/ORG/Users/SCIM_USER_ID \
  -d '{"schemas":["schemas"],"userName":"userName","name":{"givenName":"givenName","familyName":"familyName"},"emails":["octocat@github.com"]}'
JavaScript (@octokit/core.js)
await octokit.request('PUT /scim/v2/organizations/{org}/Users/{scim_user_id}', {
  org: 'org',
  scim_user_id: 'scim_user_id',
  schemas: [
    'schemas'
  ],
  userName: 'userName',
  name: {
    givenName: 'givenName',
    familyName: 'familyName'
  },
  emails: [
    'octocat@github.com'
  ]
})

Default response

Status: 200 OK
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User"
  ],
  "id": "edefdfedf-050c-11e7-8d32",
  "externalId": "a7d0f98382",
  "userName": "mona.octocat@okta.example.com",
  "name": {
    "givenName": "Mona",
    "familyName": "Octocat"
  },
  "emails": [
    {
      "value": "mona.octocat@okta.example.com",
      "type": "work",
      "primary": true
    }
  ],
  "active": true,
  "meta": {
    "resourceType": "User",
    "created": "2017-03-09T16:11:13-05:00",
    "lastModified": "2017-03-09T16:11:13-05:00",
    "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32"
  }
}

Notes


Update an attribute for a SCIM user

Allows you to change a provisioned user's individual attributes. To change a user's values, you must provide a specific Operations JSON format that contains at least one of the add, remove, or replace operations. For examples and more information on the SCIM operations format, see the SCIM specification.

Note: Complicated SCIM path selectors that include filters are not supported. For example, a path selector defined as "path": "emails[type eq \"work\"]" will not work.

Warning: If you set active:false using the replace operation (as shown in the JSON example below), it removes the user from the organization, deletes the external identity, and deletes the associated :scim_user_id.

{
  "Operations":[{
    "op":"replace",
    "value":{
      "active":false
    }
  }]
}
patch /scim/v2/organizations/{org}/Users/{scim_user_id}

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended

org string path
scim_user_id string path

Identifier generated by the GitHub SCIM endpoint.

schemas array of strings body

Required. The SCIM schema URIs.

Operations array of objects body

Required. Array of SCIM operations.

代码示例

Shell
curl \
  -X PATCH \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/scim/v2/organizations/ORG/Users/SCIM_USER_ID \
  -d '{"schemas":["schemas"],"Operations":[{}]}'
JavaScript (@octokit/core.js)
await octokit.request('PATCH /scim/v2/organizations/{org}/Users/{scim_user_id}', {
  org: 'org',
  scim_user_id: 'scim_user_id',
  schemas: [
    'schemas'
  ],
  Operations: [
    {}
  ]
})

Default response

Status: 200 OK
{
  "schemas": [
    "urn:ietf:params:scim:schemas:core:2.0:User"
  ],
  "id": "edefdfedf-050c-11e7-8d32",
  "externalId": "a7d0f98382",
  "userName": "mona.octocat@okta.example.com",
  "name": {
    "givenName": "Monalisa",
    "familyName": "Octocat"
  },
  "emails": [
    {
      "value": "mona.octocat@okta.example.com",
      "type": "work",
      "primary": true
    },
    {
      "value": "monalisa@octocat.github.com",
      "type": "home"
    }
  ],
  "active": true,
  "meta": {
    "resourceType": "User",
    "created": "2017-03-09T16:11:13-05:00",
    "lastModified": "2017-03-09T16:11:13-05:00",
    "location": "https://api.github.com/scim/v2/organizations/octo-org/Users/edefdfedf-050c-11e7-8d32"
  }
}

Notes


delete /scim/v2/organizations/{org}/Users/{scim_user_id}

参数

Name Type In Description
accept string header

Setting to application/vnd.github.v3+json is recommended

org string path
scim_user_id string path

Identifier generated by the GitHub SCIM endpoint.

代码示例

Shell
curl \
  -X DELETE \
  -H "Accept: application/vnd.github.v3+json" \
  https://api.github.com/scim/v2/organizations/ORG/Users/SCIM_USER_ID
JavaScript (@octokit/core.js)
await octokit.request('DELETE /scim/v2/organizations/{org}/Users/{scim_user_id}', {
  org: 'org',
  scim_user_id: 'scim_user_id'
})

Default Response

Status: 204 No Content

Notes


Did this doc help you?