Visitar URL original
Add query that lists SAML external identities for an Organization · Issue #168 · github/platform-samples · GitHub
The Wayback Machine - https://web.archive.org/web/20200917120425/https://github.com/github/platform-samples/issues/168
Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add query that lists SAML external identities for an Organization #168

Open
osowskit opened this issue Feb 5, 2018 · 9 comments
Open

Add query that lists SAML external identities for an Organization #168

osowskit opened this issue Feb 5, 2018 · 9 comments

Comments

@osowskit
Copy link
Contributor

@osowskit osowskit commented Feb 5, 2018

Business Plan hosted customers with SAML would like a way to programmatically query information about a GitHub user account's SAML identity. The following is a GraphQL query that accomplishes this for an Organization.

query {
  organization(login: "LOGIN") {
    samlIdentityProvider {
      ssoUrl
      externalIdentities(first: 100) {
        edges {
          node {
            guid
            samlIdentity {
              nameId
            }
            user {
              login
            }
          }
        }
      }
    }
  }
}

/cc @francisfuzz as you might be able to track down the author to see if they want to add this ☝️

@mikesimons
Copy link

@mikesimons mikesimons commented Jul 1, 2019

This query was super helpful for us as we're primarily using v3 and couldn't see a way to do this there. I found the token needs admin:org though which feels excessive for a read only query.

@AjkayAlan
Copy link

@AjkayAlan AjkayAlan commented Feb 20, 2020

This query was also super helpful for us - v3 provides their SCIM endpoint (https://developer.github.com/v3/scim/) which gets us close, but does not provide a true way to tie a GitHub identity to a SAML identity.

Using this query in v4 we are able to pull our user's verified domain email addresses and associate it to their github handle, making our notification process a lot easier.

@kamaltejaaol
Copy link

@kamaltejaaol kamaltejaaol commented Jun 2, 2020

@AjkayAlan, I'm testing on the same where the email address for SAML authentication is different from github registered email address, can you please share us the query to trigger in GraphQL

@AjkayAlan
Copy link

@AjkayAlan AjkayAlan commented Jun 2, 2020

@kamaltejaaol Unfortunately my org policy does not allow me to share code easily, specifically code I developed for our organization.

What we ended up doing was using the query provided by @osowskit above to get the SAML nameId, which corresponded to our user's primary email address associated to their enterprise account (the same address we would send emails on). Additionally, the query above gets you the user login, which is the actual github login of the associated user.

From there, you can just make a key value pair list of github login to enterprise email address. Once you have that, you should be off to the races.

In our case, we had to revoke PAT and SSH keys over a specified age limit using the credential authorizations API (https://developer.github.com/v3/orgs/#list-credential-authorizations-for-an-organization). That returns the github login, which we then look up against the list of login/email kvp's. From there, we were able to notify the users in advance that they needed to rotate their credentials to avoid disruption.

@kamaltejaaol
Copy link

@kamaltejaaol kamaltejaaol commented Jun 2, 2020

@AjkayAlan, i understand the corporate security policies, but thanks for giving the detailed explanation, i will try to work it out. Thanks again.

@gracevivi523
Copy link

@gracevivi523 gracevivi523 commented Aug 6, 2020

Hi, @osowskit
Thanks for this solution, really saved my day, however I am getting null with this query, not sure what I am missing here possibly? I have correct scope for the token and header stuff.

below is the return.
{
"data": {
"organization": {
"samlIdentityProvider": null
}
}
}

@osowskit
Copy link
Contributor Author

@osowskit osowskit commented Aug 6, 2020

@swinton @mtodd ☝️

@gracevivi523
Copy link

@gracevivi523 gracevivi523 commented Aug 7, 2020 •

Thanks @osowskit .

@swinton @mtodd , I am still stuck on it, any help will be highly appreciated.

@gracevivi523
Copy link

@gracevivi523 gracevivi523 commented Aug 7, 2020

Just did a bit more research on the issue, could it be related to SCIM is not enabled?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.