StevenWeathers / thunderdome-planning-poker

⚡ Thunderdome is an open source agile planning poker, sprint retro, and story mapping tool
https://thunderdome.dev
Apache License 2.0
408 stars 105 forks source link

LDAP auth is not working with v3 #466

Closed felipecrs closed 11 months ago

felipecrs commented 1 year ago

I deleted my DB, then I created a fresh one for v3. And LDAP does not seem to work anymore. The following error is thrown when I try to login:

thunderdome-planning-poker-postgresql-0 postgresql 2023-09-11 20:30:09.071 GMT [1] LOG:  database system is ready to accept connections
thunderdome-planning-poker-postgresql-0 postgresql 2023-09-11 20:30:23.891 GMT [171] ERROR:  relation "goose_db_version" does not exist at character 36
thunderdome-planning-poker-postgresql-0 postgresql 2023-09-11 20:30:23.891 GMT [171] STATEMENT:  SELECT version_id, is_applied from goose_db_version ORDER BY id DESC
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker {"level":"error","ts":1694464295.4833686,"caller":"user/user.go:174","msg":"get user by email query error","version":"3.1.0","error":"sql: no rows in result set","stacktrace":"github.com/StevenWeathers/thunderdome-planning-poker/db/user.(*Service).GetUserByEmail\n\t/home/runner/work/thunderdome-planning-poker/thunderdome-planning-poker/db/user/user.go:174\ngithub.com/StevenWeathers/thunderdome-planning-poker/http.(*Service).authAndCreateUserLdap\n\t/home/runner/work/thunderdome-planning-poker/thunderdome-planning-poker/http/util.go:344\ngithub.com/StevenWeathers/thunderdome-planning-poker/http.(*Service).handleLdapLogin.func1\n\t/home/runner/work/thunderdome-planning-poker/thunderdome-planning-poker/http/auth.go:120\nnet/http.HandlerFunc.ServeHTTP\n\t/opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:2122\ngo.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux.traceware.ServeHTTP\n\t/home/runner/go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux@v0.39.0/mux.go:155\ngithub.com/gorilla/mux.(*Router).ServeHTTP\n\t/home/runner/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210\nnet/http.serverHandler.ServeHTTP\n\t/opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:2936\nnet/http.(*conn).serve\n\t/opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:1995"}
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker {"level":"error","ts":1694464295.4835594,"caller":"http/util.go:347","msg":"User does not exist in database, auto-recruit","version":"3.1.0","useremail":"felipe@example.com","stacktrace":"github.com/StevenWeathers/thunderdome-planning-poker/http.(*Service).authAndCreateUserLdap\n\t/home/runner/work/thunderdome-planning-poker/thunderdome-planning-poker/http/util.go:347\ngithub.com/StevenWeathers/thunderdome-planning-poker/http.(*Service).handleLdapLogin.func1\n\t/home/runner/work/thunderdome-planning-poker/thunderdome-planning-poker/http/auth.go:120\nnet/http.HandlerFunc.ServeHTTP\n\t/opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:2122\ngo.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux.traceware.ServeHTTP\n\t/home/runner/go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux@v0.39.0/mux.go:155\ngithub.com/gorilla/mux.(*Router).ServeHTTP\n\t/home/runner/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210\nnet/http.serverHandler.ServeHTTP\n\t/opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:2936\nnet/http.(*conn).serve\n\t/opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:1995"}
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker 2023/09/11 20:31:35 http: panic serving 192.168.113.29:55512: runtime error: invalid memory address or nil pointer dereference
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker goroutine 89 [running]:
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker net/http.(*conn).serve.func1()
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:1854 +0xbf
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker panic({0xff1060, 0x2686da0})
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /opt/hostedtoolcache/go/1.20.7/x64/src/runtime/panic.go:890 +0x263
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker github.com/StevenWeathers/thunderdome-planning-poker/http.(*Service).handleLdapLogin.func1({0x1668320, 0xc0013be360}, 0xc0013af900)
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /home/runner/work/thunderdome-planning-poker/thunderdome-planning-poker/http/auth.go:129 +0x31e
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker net/http.HandlerFunc.ServeHTTP(0x1667690?, {0x1668320?, 0xc0013be360?}, 0xc000710e28?)
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:2122 +0x2f
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux.traceware.ServeHTTP({{0x116242c, 0xb}, {0x165bbc0, 0xc0003dc780}, {0x1666580, 0xc0000ba6c0}, {0x1660cc0, 0xc00036d5e0}, 0x153ff60}, {0x1667690, ...}, ...)
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /home/runner/go/pkg/mod/go.opentelemetry.io/contrib/instrumentation/github.com/gorilla/mux/otelmux@v0.39.0/mux.go:155 +0x70e
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker github.com/gorilla/mux.(*Router).ServeHTTP(0xc000001680, {0x1667690, 0xc001392460}, 0xc0013af600)
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /home/runner/go/pkg/mod/github.com/gorilla/mux@v1.8.0/mux.go:210 +0x1cf
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker net/http.serverHandler.ServeHTTP({0x1664290?}, {0x1667690, 0xc001392460}, 0xc0013af600)
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:2936 +0x316
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker net/http.(*conn).serve(0xc00091ba70, {0x16686a0, 0xc0010e7c50})
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:1995 +0x612
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker created by net/http.(*Server).Serve
thunderdome-planning-poker-5675bcfbc7-dqx2c thunderdome-planning-poker  /opt/hostedtoolcache/go/1.20.7/x64/src/net/http/server.go:3089 +0x5ed
felipecrs commented 1 year ago

Ok, actually the same problem happens in v2.41.0 too. Apparently, this issue happens when there is no user in the database yet. After trying to login again, it works.

felipecrs commented 1 year ago

Another feedback is that admin.email only seems to be effective after trying a few times as well. But for this one, maybe it's only a browser cache thing.

StevenWeathers commented 1 year ago

The admin email works only if the user is registered with that email prior to when the application starts up, so after creating the user through register you have to restart the server. This is just a utility for initial setup of the application.

felipecrs commented 1 year ago

Ok, that's not big deal. But I think the same problem I initially described happens when I don't set admin.email as well.

felipecrs commented 11 months ago

Thanks a lot, @StevenWeathers!