...
|
...
|
@@ -6,6 +6,7 @@ import ( |
|
|
"fmt"
|
|
|
"github.com/astaxie/beego/context"
|
|
|
//"github.com/opentracing/opentracing-go"
|
|
|
auth "github.com/abbot/go-http-auth"
|
|
|
"github.com/tiptok/gocomm/common"
|
|
|
"github.com/tiptok/gocomm/pkg/log"
|
|
|
"gitlab.fjmaimaimai.com/mmm-go/godevp/pkg/application/cachex"
|
...
|
...
|
@@ -154,3 +155,20 @@ func AllowCors() func(ctx *context.Context) { |
|
|
// }
|
|
|
// defer sp.Finish()
|
|
|
//}
|
|
|
|
|
|
func secret(user, pwd string) string {
|
|
|
if user == "admin" {
|
|
|
// password is "hello"
|
|
|
return "$1$dlPL2MqE$oQmn16q49SqdmhenQuNgs1"
|
|
|
}
|
|
|
return ""
|
|
|
}
|
|
|
|
|
|
func BasicAuth() func(ctx *context.Context) {
|
|
|
return func(ctx *context.Context) {
|
|
|
a := auth.NewBasicAuthenticator("example.com", secret)
|
|
|
if username := a.CheckAuth(ctx.Request); username == "" {
|
|
|
a.RequireAuth(ctx.ResponseWriter, ctx.Request)
|
|
|
}
|
|
|
}
|
|
|
} |
...
|
...
|
|