Skip to content

Commit 04c8a10

Browse files
committed
Update go-chi session
1 parent 6f25aac commit 04c8a10

File tree

6 files changed

+9
-47
lines changed

6 files changed

+9
-47
lines changed

go.mod

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ go 1.14
55
require (
66
code.gitea.io/gitea-vet v0.2.1
77
code.gitea.io/sdk/gitea v0.13.1
8-
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27
8+
gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee
99
gitea.com/lunny/levelqueue v0.3.0
1010
gitea.com/macaron/binding v0.0.0-20190822013154-a5f53841ed2b
1111
gitea.com/macaron/cache v0.0.0-20200924044943-905232fba10b

go.sum

+2-2
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ code.gitea.io/gitea-vet v0.2.1/go.mod h1:zcNbT/aJEmivCAhfmkHOlT645KNOf9W2KnkLgFj
4040
code.gitea.io/sdk/gitea v0.13.1 h1:Y7bpH2iO6Q0KhhMJfjP/LZ0AmiYITeRQlCD8b0oYqhk=
4141
code.gitea.io/sdk/gitea v0.13.1/go.mod h1:z3uwDV/b9Ls47NGukYM9XhnHtqPh/J+t40lsUrR6JDY=
4242
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
43-
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27 h1:cdb1OTNXGLwQ55gg+9tIPWufdsnrHWcIq8Qs+j/E8JU=
44-
gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27/go.mod h1:Ozg8IchVNb/Udg+ui39iHRYqVHSvf3C99ixdpLR8Vu0=
43+
gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee h1:9U6HuKUBt/cGK6T/64dEuz0r7Yp97WAAEJvXHDlY3ws=
44+
gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee/go.mod h1:Ozg8IchVNb/Udg+ui39iHRYqVHSvf3C99ixdpLR8Vu0=
4545
gitea.com/lunny/levelqueue v0.3.0 h1:MHn1GuSZkxvVEDMyAPqlc7A3cOW+q8RcGhRgH/xtm6I=
4646
gitea.com/lunny/levelqueue v0.3.0/go.mod h1:HBqmLbz56JWpfEGG0prskAV97ATNRoj5LDmPicD22hU=
4747
gitea.com/lunny/log v0.0.0-20190322053110-01b5df579c4e h1:r1en/D7xJmcY24VkHkjkcJFa+7ZWubVWPBrvsHkmHxk=

routers/routes/chi.go

+1-41
Original file line numberDiff line numberDiff line change
@@ -180,46 +180,6 @@ var (
180180
sessionManager *session.Manager
181181
)
182182

183-
func prepareOptions(options []session.Options) session.Options {
184-
var opt session.Options
185-
if len(options) > 0 {
186-
opt = options[0]
187-
}
188-
189-
if len(opt.Provider) == 0 {
190-
opt.Provider = "memory"
191-
}
192-
if len(opt.ProviderConfig) == 0 {
193-
opt.ProviderConfig = "data/sessions"
194-
}
195-
if len(opt.CookieName) == 0 {
196-
opt.CookieName = "MacaronSession"
197-
}
198-
if len(opt.CookiePath) == 0 {
199-
opt.CookiePath = "/"
200-
}
201-
if opt.Gclifetime == 0 {
202-
opt.Gclifetime = 3600
203-
}
204-
if opt.Maxlifetime == 0 {
205-
opt.Maxlifetime = opt.Gclifetime
206-
}
207-
if !opt.Secure {
208-
opt.Secure = false
209-
}
210-
if opt.IDLength == 0 {
211-
opt.IDLength = 16
212-
}
213-
if len(opt.FlashEncryptionKey) == 0 {
214-
opt.FlashEncryptionKey = ""
215-
}
216-
if len(opt.FlashEncryptionKey) == 0 {
217-
opt.FlashEncryptionKey, _ = session.NewSecret()
218-
}
219-
220-
return opt
221-
}
222-
223183
// NewChi creates a chi Router
224184
func NewChi() chi.Router {
225185
c := chi.NewRouter()
@@ -240,7 +200,7 @@ func NewChi() chi.Router {
240200
Secure: setting.SessionConfig.Secure,
241201
Domain: setting.SessionConfig.Domain,
242202
}
243-
opt = prepareOptions([]session.Options{opt})
203+
opt = session.PrepareOptions([]session.Options{opt})
244204

245205
var err error
246206
sessionManager, err = session.NewManager(opt.Provider, opt)

routers/routes/recovery.go

+1
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ func Recovery() func(next http.Handler) http.Handler {
6464

6565
lc := middlewares.Locale(w, req)
6666

67+
// TODO: this should be replaced by real session after macaron removed totally
6768
sessionStore, err := sessionManager.Start(w, req)
6869
if err != nil {
6970
// Just invoke the above recover catch

vendor/gitea.com/go-chi/session/session.go

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

vendor/modules.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ code.gitea.io/gitea-vet/checks
77
# code.gitea.io/sdk/gitea v0.13.1
88
## explicit
99
code.gitea.io/sdk/gitea
10-
# gitea.com/go-chi/session v0.0.0-20201218134809-7209fa084f27
10+
# gitea.com/go-chi/session v0.0.0-20210108030337-0cb48c5ba8ee
1111
## explicit
1212
gitea.com/go-chi/session
1313
gitea.com/go-chi/session/couchbase

0 commit comments

Comments
 (0)