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

Better Session Provider Documentation #14016

Closed
1 of 6 tasks
Skaronator opened this issue Dec 16, 2020 · 9 comments
Closed
1 of 6 tasks

Better Session Provider Documentation #14016

Skaronator opened this issue Dec 16, 2020 · 9 comments
Labels
type/docs This PR mainly updates/creates documentation

Comments

@Skaronator
Copy link

  • Gitea version (or commit ref): 1.13
  • Git version:
  • Operating system: Docker / Kubernetes
  • Database (use [x]):
    • PostgreSQL
    • MySQL
    • MSSQL
    • SQLite
  • Can you reproduce the bug at https://try.gitea.io:
    • Yes (provide example URL)
    • No
  • Log gist:

Description

It took me litterally 1 hour to figure out how to configure the sessions properly with Postgres. The offical Gitea Documentation is really lite on that topic as you can see here https://docs.gitea.io/en-us/config-cheat-sheet/#session-session

There are only 2 lines that describe how to configure it but doesn't mention how to do it exactly. A example would be great here.

After searching in the code I found out that Gitea uses a library for that and the library has a wonderfull documentation. Maybe it make sense to a) either link their documentation in the Gitea documentation or b) copy the important parts out of it and further reference them.

https://go-macaron.com/middlewares/session#postgresql

What do you think?

...

Screenshots

@noerw noerw added the type/docs This PR mainly updates/creates documentation label Dec 16, 2020
@lunny
Copy link
Member

lunny commented Jan 26, 2021

macaron has been replaced by go-chi and the session middleware has been replaced by https://gitea.com/go-chi/session

@6543
Copy link
Member

6543 commented Jan 26, 2021

@Skaronator if you like you could enhance the docu ... :) - just send a pull

@zeripath
Copy link
Contributor

The new db session provider is even simpler than any of the rest - it simply uses the gitea db so doesn't need any configuration.

@6543
Copy link
Member

6543 commented Feb 21, 2021

@zeripath we should at least mention this option for clustering ...

@ndaidong
Copy link
Contributor

@Skaronator @lunny we actually need some lines about how to store session within postgres. I've tried to change PROVIDER to postgres and PROVIDER_CONFIG to postgrest connection string, but Gitea throws error:

Apr 22 09:44:52 gs gitea[8184]: panic: pq: SSL is not enabled on the server
Apr 22 09:44:52 gs gitea[8184]: goroutine 1 [running]:
Apr 22 09:44:52 gs gitea[8184]: gitea.com/go-chi/session.Sessioner(0xc002f5d3f0, 0x1, 0x1, 0x6)
Apr 22 09:44:52 gs gitea[8184]:         /workspace/gitea/vendor/gitea.com/go-chi/session/session.go:238 +0x1a5
Apr 22 09:44:52 gs gitea[8184]: code.gitea.io/gitea/routers/routes.WebRoutes(0xc00249cf80)
Apr 22 09:44:52 gs gitea[8184]:         /workspace/gitea/routers/routes/web.go:133 +0x1b8
Apr 22 09:44:52 gs gitea[8184]: code.gitea.io/gitea/routers/routes.NormalRoutes(0xc00133be40)
Apr 22 09:44:52 gs gitea[8184]:         /workspace/gitea/routers/routes/web.go:123 +0x11b
Apr 22 09:44:52 gs gitea[8184]: code.gitea.io/gitea/cmd.runWeb(0xc00133be40, 0x0, 0x0)
Apr 22 09:44:52 gs gitea[8184]:         /workspace/gitea/cmd/web.go:138 +0x4ae
Apr 22 09:44:52 gs gitea[8184]: github.com/urfave/cli.HandleAction(0x24c10c0, 0x3728000, 0xc00133be40, 0xc00133be40, 0x0)
Apr 22 09:44:52 gs gitea[8184]:         /workspace/gitea/vendor/github.com/urfave/cli/app.go:524 +0x105
Apr 22 09:44:52 gs gitea[8184]: github.com/urfave/cli.Command.Run(0x28c963a, 0x3, 0x0, 0x0, 0x0, 0x0, 0x0, 0x2a2d0ae, 0x16, 0x0, ...)
Apr 22 09:44:52 gs gitea[8184]:         /workspace/gitea/vendor/github.com/urfave/cli/command.go:173 +0x579
Apr 22 09:44:52 gs gitea[8184]: github.com/urfave/cli.(*App).Run(0xc0011bddc0, 0xc00003c040, 0x2, 0x2, 0x0, 0x0)
Apr 22 09:44:52 gs gitea[8184]:         /workspace/gitea/vendor/github.com/urfave/cli/app.go:277 +0x808
Apr 22 09:44:52 gs gitea[8184]: main.main()
Apr 22 09:44:52 gs gitea[8184]:         /workspace/gitea/main.go:115 +0xa6a
Apr 22 09:44:52 gs systemd[1]: gitea.service: Main process exited, code=exited, status=2/INVALIDARGUMENT
Apr 22 09:44:52 gs systemd[1]: gitea.service: Failed with result 'exit-code'.

@zeripath
Copy link
Contributor

@ndaidong what is the 👎 for?

How can I be clearer:

If you set PROVIDER=db then you don't need to set anything in PROVIDER_CONFIG and the session will just use the DB configuration.

@ndaidong
Copy link
Contributor

@zeripath thank you, it works for me now, even the log show:

Apr 23 09:32:22 gs gitea[10421]: 2021/04/23 09:32:22 ...odules/session/db.go:166:GC() [I] session/DB: error garbage collecting: pq: column "created_unix" does not exist
Apr 23 09:32:23 gs gitea[10421]: 2021/04/23 09:32:23 cmd/web.go:189:listen() [I] Listen: http://0.0.0.0:18081
Apr 23 09:32:23 gs gitea[10421]: 2021/04/23 09:32:23 cmd/web.go:192:listen() [I] LFS server enabled
Apr 23 09:32:23 gs gitea[10421]: 2021/04/23 09:32:23 ...s/graceful/server.go:55:NewServer() [I] Starting new Web server: tcp:0.0.0.0:18081 on PID: 10421
Apr 23 09:32:23 gs gitea[10421]: 2021/04/23 09:32:23 ...odules/session/db.go:166:GC() [I] session/DB: error garbage collecting: pq: column "created_unix" does not exist

Anyway, it's neccessary to update the docs and example, currently there is no word mentioning to db or posgres.

[session]
; Either "memory", "file", or "redis", default is "memory"
PROVIDER = memory
; Provider config options
; memory: doesn't have any config yet
; file: session file path, e.g. `data/sessions`
; redis: network=tcp,addr=:6379,password=macaron,db=0,pool_size=100,idle_timeout=180
; mysql: go-sql-driver/mysql dsn config string, e.g. `root:password@/session_table`
PROVIDER_CONFIG = data/sessions

@lunny
Copy link
Member

lunny commented Apr 23, 2021

@ndaidong Could you help to send a PR to improve that?

@ndaidong
Copy link
Contributor

@lunny sure, my pleasure. I will send a PR this weekend.

6543 pushed a commit that referenced this issue Apr 24, 2021
Add more guide about `PROVIDER_CONFIG` when `PROVIDER` is `db` (#14016)
AbdulrhmnGhanem pushed a commit to kitspace/gitea that referenced this issue Aug 10, 2021
Add more guide about `PROVIDER_CONFIG` when `PROVIDER` is `db` (go-gitea#14016)
@go-gitea go-gitea locked and limited conversation to collaborators Oct 19, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type/docs This PR mainly updates/creates documentation
Projects
None yet
Development

No branches or pull requests

6 participants