mirror of
https://github.com/casdoor/casdoor.git
synced 2025-09-09 18:32:56 +08:00
Support defaultHttpClient.
This commit is contained in:
@@ -100,6 +100,14 @@ func (c *ApiController) GetApplicationLogin() {
|
|||||||
c.ServeJSON()
|
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
|
// @Title Login
|
||||||
// @Description login
|
// @Description login
|
||||||
// @Param oAuthParams query string true "oAuth parameters"
|
// @Param oAuthParams query string true "oAuth parameters"
|
||||||
@@ -213,7 +221,7 @@ func (c *ApiController) Login() {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
idProvider.SetHttpClient(httpClient)
|
setHttpClient(idProvider, provider.Type)
|
||||||
|
|
||||||
if form.State != beego.AppConfig.String("authState") && form.State != application.Name {
|
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)}
|
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"
|
"golang.org/x/net/proxy"
|
||||||
)
|
)
|
||||||
|
|
||||||
var httpClient *http.Client
|
var defaultHttpClient *http.Client
|
||||||
|
var proxyHttpClient *http.Client
|
||||||
|
|
||||||
func InitHttpClient() {
|
func InitHttpClient() {
|
||||||
|
// not use proxy
|
||||||
|
defaultHttpClient = http.DefaultClient
|
||||||
|
|
||||||
|
// use proxy
|
||||||
httpProxy := beego.AppConfig.String("httpProxy")
|
httpProxy := beego.AppConfig.String("httpProxy")
|
||||||
if httpProxy == "" {
|
if httpProxy == "" {
|
||||||
httpClient = &http.Client{}
|
proxyHttpClient = &http.Client{}
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -37,11 +42,11 @@ func InitHttpClient() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
tr := &http.Transport{Dial: dialer.Dial}
|
tr := &http.Transport{Dial: dialer.Dial}
|
||||||
httpClient = &http.Client{
|
proxyHttpClient = &http.Client{
|
||||||
Transport: tr,
|
Transport: tr,
|
||||||
}
|
}
|
||||||
|
|
||||||
//resp, err2 := httpClient.Get("https://google.com")
|
//resp, err2 := proxyHttpClient.Get("https://google.com")
|
||||||
//if err2 != nil {
|
//if err2 != nil {
|
||||||
// panic(err2)
|
// panic(err2)
|
||||||
//}
|
//}
|
||||||
|
@@ -56,7 +56,7 @@ type User struct {
|
|||||||
Weibo string `xorm:"weibo varchar(100)" json:"weibo"`
|
Weibo string `xorm:"weibo varchar(100)" json:"weibo"`
|
||||||
Gitee string `xorm:"gitee varchar(100)" json:"gitee"`
|
Gitee string `xorm:"gitee varchar(100)" json:"gitee"`
|
||||||
LinkedIn string `xorm:"linkedin varchar(100)" json:"linkedin"`
|
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"`
|
Ldap string `xorm:"ldap varchar(100)" json:"ldap"`
|
||||||
Properties map[string]string `json:"properties"`
|
Properties map[string]string `json:"properties"`
|
||||||
|
@@ -27,7 +27,8 @@ import AffiliationSelect from "./common/AffiliationSelect";
|
|||||||
import OAuthWidget from "./common/OAuthWidget";
|
import OAuthWidget from "./common/OAuthWidget";
|
||||||
import SelectRegionBox from "./SelectRegionBox";
|
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/theme/material-darker.css');
|
||||||
require("codemirror/mode/javascript/javascript");
|
require("codemirror/mode/javascript/javascript");
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user