Skip to content

github: add insecure flag #4

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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion authenticator.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"net/http"
"strings"
"fmt"
"crypto/tls"
)

type Authenticator interface {
Expand Down Expand Up @@ -142,7 +143,10 @@ func (a *GitHubAuth) Authenticate(organizations []string, c martini.Context, tok

req.SetBasicAuth(tokens.Access(), "x-oauth-basic")

client := http.Client{}
tr := &http.Transport{
TLSClientConfig: &tls.Config{InsecureSkipVerify: a.conf.Auth.Info.Insecure},
}
client := http.Client{Transport: tr}
res, err := client.Do(req)
if err != nil {
log.Printf("failed to retrieve organizations: %s", err)
Expand Down
9 changes: 8 additions & 1 deletion conf.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type AuthInfoConf struct {
RedirectURL string `yaml:"redirect_url"`
Endpoint string `yaml:"endpoint"`
ApiEndpoint string `yaml:"api_endpoint"`
Insecure bool `yaml:"insecure"`
}

type ProxyConf struct {
Expand All @@ -50,7 +51,13 @@ func ParseConf(path string) (*Conf, error) {
return nil, err
}

c := &Conf{}
c := &Conf{
Auth: AuthConf{
Info: AuthInfoConf{
Insecure: false,
},
},
}
if err := yaml.Unmarshal(data, c); err != nil {
return nil, err
}
Expand Down
3 changes: 3 additions & 0 deletions config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,4 +140,7 @@ auth:
if conf.Auth.Info.ApiEndpoint != "https://api.github.com" {
t.Errorf("unexpected api endpoint address: %s", conf.Auth.Info.ApiEndpoint)
}
if conf.Auth.Info.Insecure {
t.Errorf("insecure flag should be false: %s", conf.Auth.Info.Insecure)
}
}