Add base_url option to GitHub auth provider to allow selecting a custom endpoint. Fixes #572.

This commit is contained in:
Jeff Mitchell
2015-08-28 06:28:35 -07:00
parent 4d3f68a631
commit 06f7fb5dc3
3 changed files with 55 additions and 7 deletions

View File

@@ -1,6 +1,9 @@
package github
import (
"fmt"
"net/url"
"github.com/google/go-github/github"
"github.com/hashicorp/vault/logical"
"github.com/hashicorp/vault/logical/framework"
@@ -39,6 +42,14 @@ func (b *backend) pathLogin(
return nil, err
}
if config.BaseURL != "" {
parsedURL, err := url.Parse(config.BaseURL)
if err != nil {
return nil, fmt.Errorf("Successfully parsed base_url when set but failing to parse now: %s", err)
}
client.BaseURL = parsedURL
}
// Get the user
user, _, err := client.Users.Get("")
if err != nil {
@@ -108,7 +119,6 @@ func (b *backend) pathLogin(
}
}
policiesList, err := b.Map.Policies(req.Storage, teamNames...)
if err != nil {
return nil, err