mirror of
https://github.com/hashicorp/vault.git
synced 2025-08-24 16:11:08 +02:00
Merge pull request #489 from ekristen/github-fix
Fixes GitHub Authentication Bug #488
This commit is contained in:
commit
b380090c47
@ -47,12 +47,25 @@ func (b *backend) pathLogin(
|
|||||||
|
|
||||||
// Verify that the user is part of the organization
|
// Verify that the user is part of the organization
|
||||||
var org *github.Organization
|
var org *github.Organization
|
||||||
orgs, _, err := client.Organizations.List("", nil)
|
|
||||||
if err != nil {
|
orgOpt := &github.ListOptions{
|
||||||
return nil, err
|
PerPage: 100,
|
||||||
}
|
}
|
||||||
|
|
||||||
for _, o := range orgs {
|
var allOrgs []github.Organization
|
||||||
|
for {
|
||||||
|
orgs, resp, err := client.Organizations.List("", orgOpt)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
allOrgs = append(allOrgs, orgs...)
|
||||||
|
if resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
orgOpt.Page = resp.NextPage
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, o := range allOrgs {
|
||||||
if *o.Login == config.Org {
|
if *o.Login == config.Org {
|
||||||
org = &o
|
org = &o
|
||||||
break
|
break
|
||||||
@ -64,24 +77,35 @@ func (b *backend) pathLogin(
|
|||||||
|
|
||||||
// Get the teams that this user is part of to determine the policies
|
// Get the teams that this user is part of to determine the policies
|
||||||
var teamNames []string
|
var teamNames []string
|
||||||
teams, _, err := client.Organizations.ListUserTeams(nil)
|
|
||||||
if err != nil {
|
teamOpt := &github.ListOptions{
|
||||||
return nil, err
|
PerPage: 100,
|
||||||
}
|
}
|
||||||
for _, t := range teams {
|
|
||||||
|
var allTeams []github.Team
|
||||||
|
for {
|
||||||
|
teams, resp, err := client.Organizations.ListUserTeams(teamOpt)
|
||||||
|
if err != nil {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
allTeams = append(allTeams, teams...)
|
||||||
|
if resp.NextPage == 0 {
|
||||||
|
break
|
||||||
|
}
|
||||||
|
teamOpt.Page = resp.NextPage
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, t := range allTeams {
|
||||||
// We only care about teams that are part of the organization we use
|
// We only care about teams that are part of the organization we use
|
||||||
if *t.Organization.ID != *org.ID {
|
if *t.Organization.ID != *org.ID {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
|
||||||
// Append the names AND slug so we can get the policies
|
// Append the names so we can get the policies
|
||||||
// Slug is needed for teamnames with whitespaces
|
|
||||||
teamNames = append(teamNames, *t.Name)
|
teamNames = append(teamNames, *t.Name)
|
||||||
if *t.Name != *t.Slug {
|
|
||||||
teamNames = append(teamNames, *t.Slug)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
policiesList, err := b.Map.Policies(req.Storage, teamNames...)
|
policiesList, err := b.Map.Policies(req.Storage, teamNames...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
|
Loading…
x
Reference in New Issue
Block a user