Commit 63aab897 authored by icowan's avatar icowan
Browse files

代理问题

No related merge requests found
Showing with 19 additions and 20 deletions
+19 -20
...@@ -12,7 +12,7 @@ PID = .pid ...@@ -12,7 +12,7 @@ PID = .pid
HUB_ADDR = HUB_ADDR =
DOCKER_USER = hub.docker.com DOCKER_USER = hub.docker.com
DOCKER_PWD = DOCKER_PWD =
TAG = v0.2.8 TAG = v0.2.9
NAMESPACE = kplcloud NAMESPACE = kplcloud
PWD = $(shell pwd) PWD = $(shell pwd)
......
...@@ -108,6 +108,24 @@ func (c *service) AuthLoginGithubCallback(w http.ResponseWriter, r *http.Request ...@@ -108,6 +108,24 @@ func (c *service) AuthLoginGithubCallback(w http.ResponseWriter, r *http.Request
ctx := context.Background() ctx := context.Background()
// state := r.URL.Query().Get("state") // todo 它需要验证一下可以考虑使用jwt生成 先用cookie 简单处理一下吧... // state := r.URL.Query().Get("state") // todo 它需要验证一下可以考虑使用jwt生成 先用cookie 简单处理一下吧...
if httpProxy := c.config.GetString(config.SectionServer, "http_proxy"); httpProxy != "" {
_ = level.Debug(c.logger).Log("use-proxy", httpProxy)
dialer := &net.Dialer{
Timeout: time.Duration(5 * int64(time.Second)),
KeepAlive: time.Duration(5 * int64(time.Second)),
}
ctx = context.WithValue(ctx, oauth2.HTTPClient, &http.Client{
Transport: &http.Transport{
Proxy: func(_ *http.Request) (*url.URL, error) {
return url.Parse(httpProxy)
},
DialContext: dialer.DialContext,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: false,
},
},
})
}
githubOauthConfig := c.auth2Config() githubOauthConfig := c.auth2Config()
...@@ -135,25 +153,6 @@ func (c *service) AuthLoginGithubCallback(w http.ResponseWriter, r *http.Request ...@@ -135,25 +153,6 @@ func (c *service) AuthLoginGithubCallback(w http.ResponseWriter, r *http.Request
return return
} }
if httpProxy := c.config.GetString(config.SectionServer, "http_proxy"); httpProxy != "" {
_ = level.Debug(c.logger).Log("use-proxy", httpProxy)
dialer := &net.Dialer{
Timeout: time.Duration(5 * int64(time.Second)),
KeepAlive: time.Duration(5 * int64(time.Second)),
}
ctx = context.WithValue(ctx, oauth2.HTTPClient, &http.Client{
Transport: &http.Transport{
Proxy: func(_ *http.Request) (*url.URL, error) {
return url.Parse(httpProxy)
},
DialContext: dialer.DialContext,
TLSClientConfig: &tls.Config{
InsecureSkipVerify: false,
},
},
})
}
client := github.NewClient(githubOauthConfig.Client(ctx, token)) client := github.NewClient(githubOauthConfig.Client(ctx, token))
user, _, err := client.Users.Get(context.Background(), "") user, _, err := client.Users.Get(context.Background(), "")
if err != nil { if err != nil {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment