Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: middleware #208

Merged
merged 5 commits into from
May 13, 2022
Merged

feat: middleware #208

merged 5 commits into from
May 13, 2022

Conversation

huaxiabuluo
Copy link
Contributor

No description provided.

Comment on lines 10 to 18
"github.com/golang-jwt/jwt/v4"
"github.com/vesoft-inc/nebula-http-gateway/ccore/nebula/gateway/dao"
"github.com/vesoft-inc/nebula-http-gateway/ccore/nebula/gateway/pool"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/config"
"github.com/vesoft-inc/nebula-studio/server/api/studio/internal/types"
"github.com/vesoft-inc/nebula-studio/server/api/studio/pkg/ecode"
"github.com/vesoft-inc/nebula-studio/server/api/studio/pkg/utils"
"github.com/zeromicro/go-zero/rest"
"github.com/zeromicro/go-zero/rest/httpx"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

import with sort? you can make check.

@@ -0,0 +1,100 @@
package middleware
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will publish the pkg.

defer server.Stop()

// global middleware
// server.Use(auth.AuthMiddleware)
server.Use(auth.AuthMiddlewareWithConfig(&c))

// static assets handlers
utils.RegisterHandlers(server, svcCtx, embedAssets)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So, utils.RegisterHandlers is no longer needed, can it be deleted?

@CLAassistant
Copy link

CLAassistant commented May 11, 2022

CLA assistant check
All committers have signed the CLA.


svcCtx := svc.NewServiceContext(c)
server := rest.MustNewServer(c.RestConf, rest.WithNotFoundHandler(middleware.NewAssertsHandler(middleware.AssertsConfig{
Root: "assets",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you configure the Filesystem, the Root is need not.

@@ -6,6 +6,6 @@ Debug:
Enable: false
Auth:
AccessSecret: "login_secret"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

using a more strict random string?

return &types.ConnectDBResult{
Version: string(clientInfo.NebulaVersion),
Version: string(request.NebulaVersion),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

so where you real make the db connection? logics seems to be delete above?

Value: clientInfo.ClientID,
Path: "/",
HttpOnly: true,
MaxAge: 1800,
Copy link
Contributor

@nianiaJR nianiaJR May 11, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

read from the config? just make it configurable

MaxAge: 1800,
}
nsid := http.Cookie{
Name: "nsid",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In order to make the nsid conflict with other apps, you'd better make it configuarable and add a prefix like explorer-nsid. So same is the cookie field token

Comment on lines 122 to 123
w.Header().Set("Set-Cookie", token.String())
w.Header().Add("Set-Cookie", nsid.String())
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are these fileds http-only?

Copy link
Contributor

@nianiaJR nianiaJR left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@huaxiabuluo huaxiabuluo merged commit 673992e into vesoft-inc:refactor May 13, 2022
@huaxiabuluo huaxiabuluo deleted the refactor branch May 20, 2022 06:14
hetao92 pushed a commit that referenced this pull request May 26, 2022
* feat: middleware
* feat: dynamicly add query params func
* feat: common params
* update: go mod tidy
* feat: batchExec
hetao92 pushed a commit that referenced this pull request May 26, 2022
feat: mime && connectdb

store

u

文件上传、删除、预览功能实现 (#206)

feat: middleware (#208)

* feat: middleware
* feat: dynamicly add query params func
* feat: common params
* update: go mod tidy
* feat: batchExec

complete file and import task (#213)

modify upload and download
mody: go mod
refine the code
update: make check
modify return values

Refactor (#219)

* update: server-v2
* updata: format

feat: context auth (#220)

update: export module (#222)

feat: export RegisterHandlers (#223)

update: gitignore (#224)

fix: fix service init crash (#225)

update: WithErrorMessage (#226)

fix import task (#227)

fix the type conveersion problem

fix: fix import & file model (#229)
huaxiabuluo added a commit that referenced this pull request May 26, 2022
feat: mime && connectdb
feat: 文件上传、删除、预览功能实现 (#206)
feat: middleware (#208)
* feat: middleware
* feat: dynamicly add query params func
* feat: common params
* update: go mod tidy
* feat: batchExec

complete file and import task (#213)

modify upload and download
mody: go mod
refine the code
update: make check
modify return values

Refactor (#219)

* update: server-v2
* updata: format

feat: context auth (#220)

update: export module (#222)

feat: export RegisterHandlers (#223)

update: gitignore (#224)

fix: fix service init crash (#225)

update: WithErrorMessage (#226)

fix import task (#227)

fix the type conveersion problem

fix: fix import & file model (#229)

Co-authored-by: Bruce <[email protected]>
veeding pushed a commit to veeding/nebula-studio that referenced this pull request Jun 14, 2022
* feat: middleware
* feat: dynamicly add query params func
* feat: common params
* update: go mod tidy
* feat: batchExec
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants