Skip to content

Commit 5717604

Browse files
authored
Merge pull request #757 from github/jusuchin85/2024-11-19_graphql_ip-allow-lists
Add GraphQL Queries for Managing the IP Allow List (and Other Small Usability Fixes)
2 parents e92f650 + 68de171 commit 5717604

32 files changed

Lines changed: 223 additions & 18 deletions

graphql/queries/scim-emu-list-enterprise-scim-identities.graphql renamed to graphql/queries/emu-scim-list-scim-identities.graphql

File renamed without changes.

graphql/queries/scim-emu-enterprises-list-scim-identities.graphql renamed to graphql/queries/emu-scim-oidc-list-scim-identities.graphql

File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Grab current IP allow list settings for an enterprise.
2+
# This includes:
3+
# - The IP allow list entries
4+
# - The IP allow list enabled setting
5+
# - The IP allow list for GitHub Apps enabled setting
6+
7+
query GetEnterpriseIPAllowList {
8+
enterprise(slug: "ENTERPRISE_SLUG") {
9+
owner_id: id
10+
enterprise_slug: slug
11+
enterprise_owner_info: ownerInfo {
12+
is_ip_allow_list_enabled: ipAllowListEnabledSetting
13+
is_ip_allow_list_for_github_apps_enabled: ipAllowListForInstalledAppsEnabledSetting
14+
ipAllowListEntries(first: 100) {
15+
nodes {
16+
ip_allow_list_entry_id: id
17+
ip_allow_list_entry_name: name
18+
ip_allow_list_entry_value: allowListValue
19+
ip_allow_list_entry_created: createdAt
20+
is_ip_allow_list_entry_active: isActive
21+
}
22+
}
23+
}
24+
}
25+
}

graphql/queries/saml-identities-enterprise-level.graphql renamed to graphql/queries/enterprise-saml-identities.graphql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
# 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.
44
# 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. There is an example of pagination in simple-pagination-example.graphql.
55

6-
query listSSOUserIdentities($enterpriseSlug: String!) {
7-
enterprise(slug: $enterpriseSlug) {
6+
query listSSOUserIdentities {
7+
enterprise(slug: "ENTERPRISE_SLUG") {
88
ownerInfo {
99
samlIdentityProvider {
1010
externalIdentities(first: 100) {

graphql/queries/scim-identities-all-orgs-in-enterprise.graphql renamed to graphql/queries/enterprise-scim-identities-all-orgs.graphql

File renamed without changes.
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# This query is used to add an IP address to the IP allow list.
2+
# This can be used on both organizations and enterprise accounts.
3+
#
4+
# The `OWNER_ID` is the ID of the organization or enterprise account. You can
5+
# get the ID of an organization or enterprise account by executing either of
6+
# the following queries and referring to the value from `owner_id` field:
7+
#
8+
# - organizations: https://github.com/github/platform-samples/blob/master/graphql/queries/org-get-ip-allow-list.graphql
9+
# - enterprise accounts: https://github.com/github/platform-samples/blob/master/graphql/queries/enterprise-get-ip-allow-list.graphql
10+
11+
mutation AddIPAddressToIPAllowList {
12+
createIpAllowListEntry(
13+
input: {
14+
ownerId: "OWNER_ID"
15+
name: "DESCRIPTION_OF_IP_ADDRESS"
16+
allowListValue: "IP_ADDRESS"
17+
isActive: true
18+
}
19+
) {
20+
ipAllowListEntry {
21+
ip_allow_list_entry_id: id
22+
ip_allow_list_entry_name: name
23+
ip_allow_list_entry_ip_address: allowListValue
24+
ip_allow_list_entry_created: createdAt
25+
ip_allow_list_entry_updated: updatedAt
26+
is_ip_allow_list_entry_active: isActive
27+
}
28+
}
29+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This query is used to disable the IP allow list feature. This will apply to GitHub Apps only.
2+
# This can be used on both organizations and enterprise accounts.
3+
#
4+
# The `OWNER_ID` is the ID of the organization or enterprise account. You can
5+
# get the ID of an organization or enterprise account by executing either of
6+
# the following queries and referring to the value from `owner_id` field:
7+
#
8+
# - organizations: https://github.com/github/platform-samples/blob/master/graphql/queries/org-get-ip-allow-list.graphql
9+
# - enterprise accounts: https://github.com/github/platform-samples/blob/master/graphql/queries/enterprise-get-ip-allow-list.graphql
10+
11+
mutation DisableIPAllowListForGitHubAppsOnly {
12+
updateIpAllowListForInstalledAppsEnabledSetting(
13+
input: { ownerId: "OWNER_ID", settingValue: DISABLED }
14+
) {
15+
clientMutationId
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This query is used to disable the IP allow list feature. This will apply to IP addresses only.
2+
# This can be used on both organizations and enterprise accounts.
3+
#
4+
# The `OWNER_ID` is the ID of the organization or enterprise account. You can
5+
# get the ID of an organization or enterprise account by executing either of
6+
# the following queries and referring to the value from `owner_id` field:
7+
#
8+
# - organizations: https://github.com/github/platform-samples/blob/master/graphql/queries/org-get-ip-allow-list.graphql
9+
# - enterprise accounts: https://github.com/github/platform-samples/blob/master/graphql/queries/enterprise-get-ip-allow-list.graphql
10+
11+
mutation DisableAllowListForIpsOnly {
12+
updateIpAllowListEnabledSetting(
13+
input: { ownerId: "OWNER_ID", settingValue: DISABLED }
14+
) {
15+
clientMutationId
16+
}
17+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# This query is used to disable the IP allow list feature. This will apply to both IP addresses and GitHub Apps.
2+
# This can be used on both organizations and enterprise accounts.
3+
#
4+
# The `OWNER_ID` is the ID of the organization or enterprise account. You can
5+
# get the ID of an organization or enterprise account by executing either of
6+
# the following queries and referring to the value from `owner_id` field:
7+
#
8+
# - organizations: https://github.com/github/platform-samples/blob/master/graphql/queries/org-get-ip-allow-list.graphql
9+
# - enterprise accounts: https://github.com/github/platform-samples/blob/master/graphql/queries/enterprise-get-ip-allow-list.graphql
10+
11+
mutation DisableIPAllowList {
12+
updateIpAllowListEnabledSetting(
13+
input: { ownerId: "OWNER_ID", settingValue: DISABLED }
14+
) {
15+
clientMutationId
16+
}
17+
updateIpAllowListForInstalledAppsEnabledSetting(
18+
input: { ownerId: "OWNER_ID", settingValue: DISABLED }
19+
) {
20+
clientMutationId
21+
}
22+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
# This query is used to enable the IP allow list feature. This will apply to GitHub Apps only.
2+
# This can be used on both organizations and enterprise accounts.
3+
#
4+
# The `OWNER_ID` is the ID of the organization or enterprise account. You can
5+
# get the ID of an organization or enterprise account by executing either of
6+
# the following queries and referring to the value from `owner_id` field:
7+
#
8+
# - organizations: https://github.com/github/platform-samples/blob/master/graphql/queries/org-get-ip-allow-list.graphql
9+
# - enterprise accounts: https://github.com/github/platform-samples/blob/master/graphql/queries/enterprise-get-ip-allow-list.graphql
10+
11+
mutation EnableIPAllowListForGitHubAppsOnly {
12+
updateIpAllowListForInstalledAppsEnabledSetting(
13+
input: { ownerId: "OWNER_ID", settingValue: ENABLED }
14+
) {
15+
clientMutationId
16+
}
17+
}

0 commit comments

Comments
 (0)