Skip to content

Commit 5c5d573

Browse files
authored
Merge pull request #683 from github/graphql-saml-query-updates
Updating the GraphQL queries for enterprise and org member data (saml identities, scim identities, emails for EMUs)
2 parents 3beda8a + 58a3d8c commit 5c5d573

11 files changed

+211
-104
lines changed

graphql/queries/12-members-with-scim-identity-org.graphql

Lines changed: 0 additions & 24 deletions
This file was deleted.

graphql/queries/13-members-with-scim-identity-enterprise.graphql

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# This GraphQL query will print a list of all EMU (Enterprise Managed User) member email addresses, usernames, and display names in an enterprise.
2+
# This query will not work properly for enterprises that do not use EMUs, as non-EMU enterprises contain personal user accounts and therefore email addresses may be private depending on the user profile configuration.
3+
4+
{
5+
enterprise(slug: "enterprise slug") {
6+
members(first: 100) {
7+
nodes {
8+
... on EnterpriseUserAccount {
9+
login
10+
name
11+
user {
12+
email
13+
}
14+
organizations(first: 10) {
15+
nodes {
16+
login
17+
}
18+
}
19+
}
20+
}
21+
}
22+
}
23+
}

graphql/queries/enterprise-sso-member-details.graphql

Lines changed: 0 additions & 28 deletions
This file was deleted.
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# For GitHub Enterprise Cloud enterprises that have SAML configured at the enterprise level, this query will print a list of the first 100 SAML identities (specifically the `nameId` attribute value) in the enterprise and the linked GitHub username (if the SAML identity is linked).
2+
# An email address often gets used for the SAML `nameId` value, but this is not always the case.
3+
# If the Identity Provider has sent an `emails` attribute/value in a previous SAML response for enterprise member(s), it also possible to add the `emails` attribute in the `samlIdentity` section right below `nameID` and query for this SAML identity attribute value as well.
4+
# If there are a large number of identities/users (greater than 100), pagination will need to be used. See https://graphql.org/learn/pagination/ for details on pagination.
5+
6+
query listSSOUserIdentities ($enterpriseName:String!) {
7+
enterprise(slug: $enterpriseName) {
8+
ownerInfo {
9+
samlIdentityProvider {
10+
externalIdentities(first: 100) {
11+
totalCount
12+
edges {
13+
node {
14+
guid
15+
samlIdentity {
16+
nameId
17+
}
18+
user {
19+
login
20+
}
21+
}
22+
}
23+
pageInfo {
24+
hasNextPage
25+
endCursor
26+
}
27+
}
28+
}
29+
}
30+
}
31+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# For GitHub Enterprise Cloud organizations that have SAML configured at the organization level, this query will print out a list of the first 100 SAML identities (specifically the `nameid` attribute value in these SAML identities) in the organization and the GitHub username linked to them.
2+
# This query can be used to see which users in a GitHub Enterprise Cloud organization have a linked SAML identity.
3+
# This query will not print out a user username (`login`) value if there is not a GitHub user account linked to this SAML identity.
4+
# If there are a large number of identities/users (greater than 100), pagination will need to be used. See https://graphql.org/learn/pagination/ for details on pagination.
5+
6+
7+
query OrgSAMLidentities {
8+
organization(login: "organization name") {
9+
samlIdentityProvider {
10+
externalIdentities(first: 100) {
11+
edges {
12+
node {
13+
samlIdentity {
14+
nameId
15+
}
16+
user {
17+
login
18+
}
19+
}
20+
}
21+
pageInfo {
22+
endCursor
23+
}
24+
}
25+
}
26+
}
27+
}
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
# For GitHub Enterprise Cloud enterprises that are using Enterprise Managed Users (EMUs) and have Azure AD OIDC setup in the enterprise authentication settings, this query will print a list of the first 100 SCIM identities and their GitHub usernames.
2+
# The SCIM identity attributes displayed in the query results will include the SCIM `username`, the first (`givenName`) and last (familyName`) name, and the `emails` attribute value.
3+
# The SCIM identity attributes that are stored in a GitHub EMU enterprise are based on the attributes that the external Identity Provider has previously sent for each user via the SCIM integration which leverages the GitHub EMU SCIM API.
4+
# The query will not work for EMU enterprises that are using SAML as the enterprise authentication method.
5+
6+
{
7+
enterprise(slug: "enterprise slug") {
8+
ownerInfo {
9+
oidcProvider {
10+
id
11+
providerType
12+
tenantId
13+
externalIdentities(first: 100) {
14+
totalCount
15+
edges {
16+
node {
17+
scimIdentity {
18+
username
19+
givenName
20+
familyName
21+
emails {
22+
primary
23+
type
24+
value
25+
}
26+
}
27+
user {
28+
login
29+
name
30+
}
31+
}
32+
}
33+
}
34+
}
35+
}
36+
}
37+
}
38+
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# For GitHub Enterprise Cloud enterprises that are using Enterprise Managed Users (EMUs) and SAML authentication, this GraphQL query will print a list (first 100 in this example) of the SCIM identities (specifically, the SCIM `username` attribute) and the linked GitHub usernames.
2+
# This query will not work for enterprises that do not use EMUs, as SCIM provisioning cannot be enabled at the enterprise level for enterprises that do not use EMUs.j
3+
# Modifying this query to also show member SAML identities will not work for EMU enterprises, since SAML identities are not currently stored for enterprises that use EMUs.
4+
# This query will also not work for EMU enterprises that are using Azure AD OIDC for authentication.
5+
# If there are a large number of identities/users (greater than 100), pagination will need to be used. See https://graphql.org/learn/pagination/ for details on pagination.
6+
7+
query {
8+
enterprise(slug: "enterprise slug") {
9+
ownerInfo {
10+
samlIdentityProvider {
11+
externalIdentities(first: 100) {
12+
pageInfo {
13+
hasNextPage
14+
endCursor
15+
}
16+
edges{
17+
node{
18+
scimIdentity {
19+
username
20+
}
21+
user {
22+
login
23+
name
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
}
31+
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# For GitHub Enterprise Cloud organizations that are in an enterprise and have SAML and SCIM configured at the organization level, this query will print out a list of the first 100 SCIM identities (specifically the `username` attribute value in these SCIM identities) in the first 100 organizations in the enterprise.
2+
# The query will also print out the linked GitHub username, if the SCIM identity is linked to a user. A SCIM identity can be unlinked if a user has not logged in with their GitHub.com user account, accepted the invitation and authenticated via SAML to link their SAML/SCIM identity.
3+
# This query will not print out a SCIM identity (`username` attribute) for members if an organization is not using SCIM provisioning, or if a user does not have a linked SCIM identity.
4+
# This query will not work for GitHub Enterprise Cloud enterprises that are using Enterprise Managed Users (EMUs).
5+
6+
query ($enterprise: String!) {
7+
enterprise(slug: $enterprise) {
8+
organizations(first: 100) {
9+
nodes {
10+
samlIdentityProvider {
11+
ssoUrl
12+
externalIdentities(first: 100) {
13+
edges {
14+
node {
15+
user {
16+
login
17+
email
18+
}
19+
scimIdentity {
20+
username
21+
}
22+
}
23+
}
24+
}
25+
}
26+
}
27+
}
28+
}
29+
}
30+
31+
variables {
32+
"enterprise": "enterprise"
33+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
# For GitHub Enterprise Cloud organizations that have SAML and SCIM provisioning configured at the organization level, this query will print out a list of the first 100 SCIM identities (specifically the `username` attribute value in these SCIM identities) in the organization.
2+
# The query will also print out the linked GitHub username, if the SCIM identity is linked to a user. A SCIM identity can be unlinked if a user has not logged in with their GitHub.com user account, accepted the invitation and authenticated via SAML to link their SAML/SCIM identity.
3+
# This query will not print out a SCIM identity (`username` attribute) for members if an organization is not using SCIM provisioning, or if a user does not have a linked SCIM identity.
4+
5+
6+
query ($organization: String!) {
7+
organization(login: $organization) {
8+
samlIdentityProvider {
9+
ssoUrl
10+
externalIdentities(first: 100) {
11+
edges {
12+
node {
13+
user {
14+
login
15+
}
16+
scimIdentity {
17+
username
18+
}
19+
}
20+
}
21+
}
22+
}
23+
}
24+
}
25+
26+
variables {
27+
"organization": "github"
28+
}

0 commit comments

Comments
 (0)