mirror of
https://github.com/astaxie/beego.git
synced 2024-11-22 00:40:56 +00:00
Merge remote-tracking branch 'origin/develop' into ftr/middleware
This commit is contained in:
commit
aa3987f816
2
.gitignore
vendored
2
.gitignore
vendored
@ -7,3 +7,5 @@ beego.iml
|
|||||||
|
|
||||||
_beeTmp
|
_beeTmp
|
||||||
_beeTmp2
|
_beeTmp2
|
||||||
|
pkg/_beeTmp
|
||||||
|
pkg/_beeTmp2
|
||||||
|
@ -12,12 +12,14 @@ please let us know if anything feels wrong or incomplete.
|
|||||||
### Pull requests
|
### Pull requests
|
||||||
|
|
||||||
First of all. beego follow the gitflow. So please send you pull request
|
First of all. beego follow the gitflow. So please send you pull request
|
||||||
to **develop** branch. We will close the pull request to master branch.
|
to **develop-2** branch. We will close the pull request to master branch.
|
||||||
|
|
||||||
We are always happy to receive pull requests, and do our best to
|
We are always happy to receive pull requests, and do our best to
|
||||||
review them as fast as possible. Not sure if that typo is worth a pull
|
review them as fast as possible. Not sure if that typo is worth a pull
|
||||||
request? Do it! We will appreciate it.
|
request? Do it! We will appreciate it.
|
||||||
|
|
||||||
|
Don't forget to rebase your commits!
|
||||||
|
|
||||||
If your pull request is not accepted on the first try, don't be
|
If your pull request is not accepted on the first try, don't be
|
||||||
discouraged! Sometimes we can make a mistake, please do more explaining
|
discouraged! Sometimes we can make a mistake, please do more explaining
|
||||||
for us. We will appreciate it.
|
for us. We will appreciate it.
|
||||||
|
2
app.go
2
app.go
@ -197,7 +197,7 @@ func (app *App) Run(mws ...MiddleWare) {
|
|||||||
pool.AppendCertsFromPEM(data)
|
pool.AppendCertsFromPEM(data)
|
||||||
app.Server.TLSConfig = &tls.Config{
|
app.Server.TLSConfig = &tls.Config{
|
||||||
ClientCAs: pool,
|
ClientCAs: pool,
|
||||||
ClientAuth: tls.RequireAndVerifyClientCert,
|
ClientAuth: BConfig.Listen.ClientAuth,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if err := app.Server.ListenAndServeTLS(BConfig.Listen.HTTPSCertFile, BConfig.Listen.HTTPSKeyFile); err != nil {
|
if err := app.Server.ListenAndServeTLS(BConfig.Listen.HTTPSCertFile, BConfig.Listen.HTTPSKeyFile); err != nil {
|
||||||
|
@ -21,6 +21,7 @@ import (
|
|||||||
"reflect"
|
"reflect"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strings"
|
"strings"
|
||||||
|
"crypto/tls"
|
||||||
|
|
||||||
"github.com/astaxie/beego/config"
|
"github.com/astaxie/beego/config"
|
||||||
"github.com/astaxie/beego/context"
|
"github.com/astaxie/beego/context"
|
||||||
@ -65,6 +66,7 @@ type Listen struct {
|
|||||||
HTTPSCertFile string
|
HTTPSCertFile string
|
||||||
HTTPSKeyFile string
|
HTTPSKeyFile string
|
||||||
TrustCaFile string
|
TrustCaFile string
|
||||||
|
ClientAuth tls.ClientAuthType
|
||||||
EnableAdmin bool
|
EnableAdmin bool
|
||||||
AdminAddr string
|
AdminAddr string
|
||||||
AdminPort int
|
AdminPort int
|
||||||
@ -150,6 +152,9 @@ func init() {
|
|||||||
filename = os.Getenv("BEEGO_RUNMODE") + ".app.conf"
|
filename = os.Getenv("BEEGO_RUNMODE") + ".app.conf"
|
||||||
}
|
}
|
||||||
appConfigPath = filepath.Join(WorkPath, "conf", filename)
|
appConfigPath = filepath.Join(WorkPath, "conf", filename)
|
||||||
|
if configPath := os.Getenv("BEEGO_CONFIG_PATH"); configPath != "" {
|
||||||
|
appConfigPath = configPath
|
||||||
|
}
|
||||||
if !utils.FileExists(appConfigPath) {
|
if !utils.FileExists(appConfigPath) {
|
||||||
appConfigPath = filepath.Join(AppPath, "conf", filename)
|
appConfigPath = filepath.Join(AppPath, "conf", filename)
|
||||||
if !utils.FileExists(appConfigPath) {
|
if !utils.FileExists(appConfigPath) {
|
||||||
@ -231,6 +236,7 @@ func newBConfig() *Config {
|
|||||||
AdminPort: 8088,
|
AdminPort: 8088,
|
||||||
EnableFcgi: false,
|
EnableFcgi: false,
|
||||||
EnableStdIo: false,
|
EnableStdIo: false,
|
||||||
|
ClientAuth: tls.RequireAndVerifyClientCert,
|
||||||
},
|
},
|
||||||
WebConfig: WebConfig{
|
WebConfig: WebConfig{
|
||||||
AutoRender: true,
|
AutoRender: true,
|
||||||
|
@ -150,7 +150,7 @@ func (ctx *Context) XSRFToken(key string, expire int64) string {
|
|||||||
token, ok := ctx.GetSecureCookie(key, "_xsrf")
|
token, ok := ctx.GetSecureCookie(key, "_xsrf")
|
||||||
if !ok {
|
if !ok {
|
||||||
token = string(utils.RandomCreateBytes(32))
|
token = string(utils.RandomCreateBytes(32))
|
||||||
ctx.SetSecureCookie(key, "_xsrf", token, expire)
|
ctx.SetSecureCookie(key, "_xsrf", token, expire, "", "", true, true)
|
||||||
}
|
}
|
||||||
ctx._xsrfToken = token
|
ctx._xsrfToken = token
|
||||||
}
|
}
|
||||||
|
@ -17,7 +17,10 @@ package context
|
|||||||
import (
|
import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"net/http/httptest"
|
"net/http/httptest"
|
||||||
|
"strings"
|
||||||
"testing"
|
"testing"
|
||||||
|
|
||||||
|
"github.com/stretchr/testify/assert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestXsrfReset_01(t *testing.T) {
|
func TestXsrfReset_01(t *testing.T) {
|
||||||
@ -44,4 +47,8 @@ func TestXsrfReset_01(t *testing.T) {
|
|||||||
if token == c._xsrfToken {
|
if token == c._xsrfToken {
|
||||||
t.FailNow()
|
t.FailNow()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ck := c.ResponseWriter.Header().Get("Set-Cookie")
|
||||||
|
assert.True(t, strings.Contains(ck, "Secure"))
|
||||||
|
assert.True(t, strings.Contains(ck, "HttpOnly"))
|
||||||
}
|
}
|
||||||
|
@ -70,10 +70,11 @@ func TestReconnect(t *testing.T) {
|
|||||||
log.Informational("informational 2")
|
log.Informational("informational 2")
|
||||||
|
|
||||||
// Check if there was a second connection attempt
|
// Check if there was a second connection attempt
|
||||||
select {
|
// close this because we moved the codes to pkg/logs
|
||||||
case second := <-newConns:
|
// select {
|
||||||
second.Close()
|
// case second := <-newConns:
|
||||||
default:
|
// second.Close()
|
||||||
t.Error("Did not reconnect")
|
// default:
|
||||||
}
|
// t.Error("Did not reconnect")
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
@ -14,14 +14,11 @@
|
|||||||
|
|
||||||
package logs
|
package logs
|
||||||
|
|
||||||
import (
|
// it often failed. And we moved this to pkg/logs,
|
||||||
"testing"
|
// so we ignore it
|
||||||
"time"
|
// func TestSmtp(t *testing.T) {
|
||||||
)
|
// log := NewLogger(10000)
|
||||||
|
// log.SetLogger("smtp", `{"username":"beegotest@gmail.com","password":"xxxxxxxx","host":"smtp.gmail.com:587","sendTos":["xiemengjun@gmail.com"]}`)
|
||||||
func TestSmtp(t *testing.T) {
|
// log.Critical("sendmail critical")
|
||||||
log := NewLogger(10000)
|
// time.Sleep(time.Second * 30)
|
||||||
log.SetLogger("smtp", `{"username":"beegotest@gmail.com","password":"xxxxxxxx","host":"smtp.gmail.com:587","sendTos":["xiemengjun@gmail.com"]}`)
|
// }
|
||||||
log.Critical("sendmail critical")
|
|
||||||
time.Sleep(time.Second * 30)
|
|
||||||
}
|
|
||||||
|
@ -150,7 +150,7 @@ func (ctx *Context) XSRFToken(key string, expire int64) string {
|
|||||||
token, ok := ctx.GetSecureCookie(key, "_xsrf")
|
token, ok := ctx.GetSecureCookie(key, "_xsrf")
|
||||||
if !ok {
|
if !ok {
|
||||||
token = string(utils.RandomCreateBytes(32))
|
token = string(utils.RandomCreateBytes(32))
|
||||||
ctx.SetSecureCookie(key, "_xsrf", token, expire)
|
ctx.SetSecureCookie(key, "_xsrf", token, expire, "", "", true, true)
|
||||||
}
|
}
|
||||||
ctx._xsrfToken = token
|
ctx._xsrfToken = token
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user