mirror of
https://github.com/casdoor/casdoor.git
synced 2025-05-23 02:35:49 +08:00
Support defaultHttpClient.
This commit is contained in:
parent
629ae5a54b
commit
1a2d85102c
@ -100,6 +100,14 @@ func (c *ApiController) GetApplicationLogin() {
|
||||
c.ServeJSON()
|
||||
}
|
||||
|
||||
func setHttpClient(idProvider idp.IdProvider, providerType string) {
|
||||
if providerType == "GitHub" || providerType == "Google" || providerType == "Facebook" || providerType == "LinkedIn" {
|
||||
idProvider.SetHttpClient(proxyHttpClient)
|
||||
} else {
|
||||
idProvider.SetHttpClient(defaultHttpClient)
|
||||
}
|
||||
}
|
||||
|
||||
// @Title Login
|
||||
// @Description login
|
||||
// @Param oAuthParams query string true "oAuth parameters"
|
||||
@ -213,7 +221,7 @@ func (c *ApiController) Login() {
|
||||
return
|
||||
}
|
||||
|
||||
idProvider.SetHttpClient(httpClient)
|
||||
setHttpClient(idProvider, provider.Type)
|
||||
|
||||
if form.State != beego.AppConfig.String("authState") && form.State != application.Name {
|
||||
resp = &Response{Status: "error", Msg: fmt.Sprintf("state expected: \"%s\", but got: \"%s\"", beego.AppConfig.String("authState"), form.State)}
|
||||
|
@ -21,12 +21,17 @@ import (
|
||||
"golang.org/x/net/proxy"
|
||||
)
|
||||
|
||||
var httpClient *http.Client
|
||||
var defaultHttpClient *http.Client
|
||||
var proxyHttpClient *http.Client
|
||||
|
||||
func InitHttpClient() {
|
||||
// not use proxy
|
||||
defaultHttpClient = http.DefaultClient
|
||||
|
||||
// use proxy
|
||||
httpProxy := beego.AppConfig.String("httpProxy")
|
||||
if httpProxy == "" {
|
||||
httpClient = &http.Client{}
|
||||
proxyHttpClient = &http.Client{}
|
||||
return
|
||||
}
|
||||
|
||||
@ -37,11 +42,11 @@ func InitHttpClient() {
|
||||
}
|
||||
|
||||
tr := &http.Transport{Dial: dialer.Dial}
|
||||
httpClient = &http.Client{
|
||||
proxyHttpClient = &http.Client{
|
||||
Transport: tr,
|
||||
}
|
||||
|
||||
//resp, err2 := httpClient.Get("https://google.com")
|
||||
//resp, err2 := proxyHttpClient.Get("https://google.com")
|
||||
//if err2 != nil {
|
||||
// panic(err2)
|
||||
//}
|
||||
|
@ -56,7 +56,7 @@ type User struct {
|
||||
Weibo string `xorm:"weibo varchar(100)" json:"weibo"`
|
||||
Gitee string `xorm:"gitee varchar(100)" json:"gitee"`
|
||||
LinkedIn string `xorm:"linkedin varchar(100)" json:"linkedin"`
|
||||
WeCom string `xorm:"wecom varchar(100)" json:"we_com"`
|
||||
Wecom string `xorm:"wecom varchar(100)" json:"wecom"`
|
||||
|
||||
Ldap string `xorm:"ldap varchar(100)" json:"ldap"`
|
||||
Properties map[string]string `json:"properties"`
|
||||
|
@ -27,7 +27,8 @@ import AffiliationSelect from "./common/AffiliationSelect";
|
||||
import OAuthWidget from "./common/OAuthWidget";
|
||||
import SelectRegionBox from "./SelectRegionBox";
|
||||
|
||||
import "codemirror/lib/codemirror.css"
|
||||
import {Controlled as CodeMirror} from 'react-codemirror2';
|
||||
import "codemirror/lib/codemirror.css";
|
||||
require('codemirror/theme/material-darker.css');
|
||||
require("codemirror/mode/javascript/javascript");
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user