Skip to content

Commit

Permalink
modify sessionID as res.data
Browse files Browse the repository at this point in the history
  • Loading branch information
lixuanxian committed Mar 27, 2024
1 parent 644cc24 commit 66a966b
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 15 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM golang:1.13.15-buster as builder
FROM golang:1-1.22-bookworm as builder
# Set the working directory to /app
WORKDIR /nebula-http-gateway
# Copy the current directory contents into the container at /app
Expand All @@ -7,7 +7,7 @@ COPY . /nebula-http-gateway
ENV GOPROXY https://goproxy.cn
RUN go build

FROM golang:1.13.15-buster
FROM golang:1-1.22-bookworm

WORKDIR /root
COPY --from=builder ./nebula-http-gateway .
Expand Down
2 changes: 1 addition & 1 deletion conf/app.conf
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,4 @@ logspath = "./logs/"
loglevel = "info"
uploadspath = "./uploads/"
sqlitedbfilepath = "./tasks.db"
sessionkey = "common-nsid"
sessionkey = "nsid"
5 changes: 2 additions & 3 deletions controllers/db.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,12 @@ func (this *DatabaseController) Connect() {
if err == nil {
nsid := info.ClientID
res.Code = 0
m := make(map[string]types.Any)
m["nsid"] = nsid
res.Data = nsid
this.Ctx.SetCookie("Secure", "true")
this.Ctx.SetCookie("SameSite", "Strict")
this.SetSession(beego.AppConfig.String("sessionkey"), nsid)

//force session id to res.data
res.Data = this.CruSession.SessionID()
res.Message = "Login successfully"
} else {
res.Code = -1
Expand Down
16 changes: 7 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import (
_ "github.com/vesoft-inc/nebula-http-gateway/routers"

"github.com/vesoft-inc/nebula-http-gateway/ccore/nebula/gateway/pool"

"github.com/astaxie/beego/plugins/cors"
)

func main() {
Expand Down Expand Up @@ -111,13 +109,13 @@ func main() {
}()

// InsertFilter is used to provide a filtering function
beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
AllowOrigins: []string{"*"},
AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Methods", "Access-Control-Allow-Headers", "Content-Type"},
ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Methods", "Access-Control-Allow-Headers", "Content-Type"},
AllowCredentials: true,
}))
// beego.InsertFilter("*", beego.BeforeRouter, cors.Allow(&cors.Options{
// AllowOrigins: []string{"*"},
// AllowMethods: []string{"GET", "POST", "PUT", "DELETE", "OPTIONS"},
// AllowHeaders: []string{"Origin", "Authorization", "Access-Control-Allow-Origin", "Access-Control-Allow-Methods", "Access-Control-Allow-Headers", "Content-Type"},
// ExposeHeaders: []string{"Content-Length", "Access-Control-Allow-Origin", "Access-Control-Allow-Methods", "Access-Control-Allow-Headers", "Content-Type"},
// AllowCredentials: true,
// }))

beego.Run()

Expand Down

0 comments on commit 66a966b

Please sign in to comment.