wiltonsr / ldapAuth

An open source Traefik Middleware that enables authentication via LDAP in a similar way to Traefik Enterprise
https://plugins.traefik.io/plugins/628c9eb7ffc0cd18356a979c/ldap-auth
Apache License 2.0
111 stars 10 forks source link

Panic for cache sessions while traefik starting #28

Closed mtsinput closed 1 year ago

mtsinput commented 1 year ago

For version 0.0.19 I got a panic error INFO: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: Starting ldap_auth@docker Middleware... DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: Enabled => 'true' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: LogLevel => 'DEBUG' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: URL => 'ldap://example.my.server' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: Port => '389' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: CacheTimeout => '300' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: CacheCookieName => 'ldapAuth_session_token' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: CacheKey => 'super-secret-key' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: UseTLS => 'true' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: StartTLS => 'true' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: CertificateAuthority => '' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: InsecureSkipVerify => 'false' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: Attribute => 'uid' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: SearchFilter => '' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: BaseDN => 'dc=example,dc=com' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: BindDN => 'cn=readonly,dc=example,dc=com' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: BindPassword => 'super_pass' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: ForwardUsername => 'true' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: ForwardUsernameHeader => 'Username' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: ForwardAuthorization => 'false' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: ForwardExtraLdapHeaders => 'false' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: WWWAuthenticateHeader => 'true' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: WWWAuthenticateHeaderRealm => '' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: AllowedGroups => '[]' DEBUG: ldapAuth: 2022/11/14 18:41:31 restricted.go:51: Username => '' time="2022-11-14T18:41:31Z" level=error msg="plugins-storage/sources/gop-1256848229/src/github.com/wiltonsr/ldapAuth/vendor/github.com/gorilla/sessions/store.go:117:2: panic" plugin=plugin-ldapAuth module=github.com/wiltonsr/ldapAuth time="2022-11-14T18:41:31Z" level=error msg="plugins-storage/sources/gop-1256848229/src/github.com/wiltonsr/ldapAuth/vendor/github.com/gorilla/sessions/store.go:52:11: panic" plugin=plugin-ldapAuth module=github.com/wiltonsr/ldapAuth time="2022-11-14T18:41:31Z" level=error msg="plugins-storage/sources/gop-1256848229/src/github.com/wiltonsr/ldapAuth/ldapauth.go:105:12: panic" plugin=plugin-ldapAuth module=github.com/wiltonsr/ldapAuth time="2022-11-14T18:41:31Z" level=error msg="Error in Go routine: plugins-storage/sources/gop-1256848229/src/github.com/wiltonsr/ldapAuth/vendor/github.com/gorilla/sessions/store.go:120:24: invalid type interface {}" time="2022-11-14T18:41:31Z" level=error msg="Stack: goroutine 59 [running]:\nruntime/debug.Stack()\n\truntime/debug/stack.go:24 +0x65\ngithub.com/traefik/traefik/v2/pkg/safe.defaultRecoverGoroutine({0x3719e00, 0xc0034bdd58})\n\tgithub.com/traefik/traefik/v2/pkg/safe/routine.go:66 +0xa5\ngithub.com/traefik/traefik/v2/pkg/safe.GoWithRecover.func1.1()\n\tgithub.com/traefik/traefik/v2/pkg/safe/routine.go:56 +0x36\npanic({0x3719e00, 0xc0034bdd58})\n\truntime/panic.go:1038 +0x215\ngithub.com/traefik/yaegi/interp.runCfg.func1()\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:192 +0x145\npanic({0x3719e00, 0xc0034bdd58})\n\truntime/panic.go:1038 +0x215\ngithub.com/traefik/yaegi/interp.runCfg.func1()\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:192 +0x145\npanic({0x3719e00, 0xc0034bdd58})\n\truntime/panic.go:1038 +0x215\ngithub.com/traefik/yaegi/interp.runCfg.func1()\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:192 +0x145\npanic({0x3719e00, 0xc0034bdd58})\n\truntime/panic.go:1038 +0x215\ngithub.com/traefik/yaegi/interp.genValueRangeArray.func2(0x3447ca0)\n\tgithub.com/traefik/yaegi@v0.13.0/interp/value.go:272 +0x405\ngithub.com/traefik/yaegi/interp._range.func4(0xc002db3b80)\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:2803 +0x42\ngithub.com/traefik/yaegi/interp.runCfg(0xc001cc3d40, 0xc002db3b80, 0x0, 0x30332a0)\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:200 +0x2ac\ngithub.com/traefik/yaegi/interp.call.func9(0xc002db38c0)\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:1433 +0x94e\ngithub.com/traefik/yaegi/interp.runCfg(0xc001caf560, 0xc002db38c0, 0xc002c6a410, 0x2f95240)\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:200 +0x2ac\ngithub.com/traefik/yaegi/interp.call.func9(0xc002db36b0)\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:1433 +0x94e\ngithub.com/traefik/yaegi/interp.runCfg(0xc000e34a20, 0xc002db36b0, 0x39, 0x3037060)\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:200 +0x2ac\ngithub.com/traefik/yaegi/interp.genFunctionWrapper.func2.1({0xc0034b2120, 0x4, 0x8})\n\tgithub.com/traefik/yaegi@v0.13.0/interp/run.go:1022 +0x4a5\nreflect.Value.call({0xc0020c0a80, 0xc0020d7980, 0x7fd0e9badf18}, {0x3914939, 0x4}, {0xc002c6b418, 0x4, 0xc80038})\n\treflect/value.go:556 +0x845\nreflect.Value.Call({0xc0020c0a80, 0xc0020d7980, 0xc0034af8c0}, {0xc002c6b418, 0x4, 0x4})\n\treflect/value.go:339 +0xc5\ngithub.com/traefik/traefik/v2/pkg/plugins.middlewareBuilder.newHandler({{0xc0020c0a80, 0xc0020d7980, 0x13}, {0xc00209f920, 0xc0020d7c50, 0x13}}, {0x42e8f60, 0xc000c06f30}, {0x427e8a0, 0xc000c06f00}, ...)\n\tgithub.com/traefik/traefik/v2/pkg/plugins/middlewares.go:62 +0x336\ngithub.com/traefik/traefik/v2/pkg/plugins.(Middleware).NewHandler(...)\n\tgithub.com/traefik/traefik/v2/pkg/plugins/middlewares.go:129\ngithub.com/traefik/traefik/v2/pkg/server/middleware.(Builder).buildConstructor.func23({0x427e8a0, 0xc000c06f00})\n\tgithub.com/traefik/traefik/v2/pkg/server/middleware/middlewares.go:359 +0x3c\ngithub.com/traefik/traefik/v2/pkg/middlewares/tracing.Wrap.func1({0x427e8a0, 0xc000c06f00})\n\tgithub.com/traefik/traefik/v2/pkg/middlewares/tracing/wrapper.go:24 +0x5a\ngithub.com/traefik/traefik/v2/pkg/server/middleware.(Builder).BuildChain.func1({0x427e8a0, 0xc000c06f00})\n\tgithub.com/traefik/traefik/v2/pkg/server/middleware/middlewares.go:80 +0xf7\ngithub.com/containous/alice.Chain.Then({{0xc0034998f0, 0xc0034998f8, 0xc000c069c0}}, {0x427e5c0, 0xc0034998e0})\n\tgithub.com/containous/alice@v0.0.0-20181107144136-d83ebdd94cbd/chain.go:51 +0x90\ngithub.com/traefik/traefik/v2/pkg/server/router.(Manager).buildHTTPHandler(0xc002c6bd90, {0x42e8f60, 0xc000c069c0}, 0xc0033be460, {0xc002f93ae8, 0xc002c6b838})\n\tgithub.com/traefik/traefik/v2/pkg/server/router/router.go:190 +0x5a5\ngithub.com/traefik/traefik/v2/pkg/server/router.(Manager).buildRouterHandler(0xc002c6bd90, {0x42e8f60, 0xc000c069c0}, {0xc002f93ae8, 0x13}, 0xc00349e5c0)\n\tgithub.com/traefik/traefik/v2/pkg/server/router/router.go:144 +0xac\ngithub.com/traefik/traefik/v2/pkg/server/router.(Manager).buildEntryPointHandler(0x42e8ef0, {0x42e8f60, 0xc000b77a70}, 0x1)\n\tgithub.com/traefik/traefik/v2/pkg/server/router/router.go:114 +0x1ea\ngithub.com/traefik/traefik/v2/pkg/server/router.(Manager).BuildHandlers(0xc002c6bd90, {0x42e8ef0, 0xc00013e020}, {0xc0020d4e80, 0x0, 0x4}, 0x0)\n\tgithub.com/traefik/traefik/v2/pkg/server/router/router.go:68 +0x27b\ngithub.com/traefik/traefik/v2/pkg/server.(RouterFactory).CreateRouters(0xc0020e4460, 0xc003329380)\n\tgithub.com/traefik/traefik/v2/pkg/server/routerfactory.go:78 +0x26a\nmain.switchRouter.func1({0xc000b8ebd0, 0xc002ffb800, 0xc0033154c0, 0xc000b8ec00})\n\tgithub.com/traefik/traefik/v2/cmd/traefik/traefik.go:388 +0x92\ngithub.com/traefik/traefik/v2/pkg/server.(ConfigurationWatcher).applyConfigurations(0xc0020e44d0, {0x42e8eb8, 0xc00009d240})\n\tgithub.com/traefik/traefik/v2/pkg/server/configurationwatcher.go:172 +0x225\ngithub.com/traefik/traefik/v2/pkg/safe.(Pool).GoCtx.func1()\n\tgithub.com/traefik/traefik/v2/pkg/safe/routine.go:36 +0x66\ngithub.com/traefik/traefik/v2/pkg/safe.GoWithRecover.func1()\n\tgithub.com/traefik/traefik/v2/pkg/safe/routine.go:59 +0x5b\ncreated by github.com/traefik/traefik/v2/pkg/safe.GoWithRecover\n\tgithub.com/traefik/traefik/v2/pkg/safe/routine.go:53 +0x77\n"

wiltonsr commented 1 year ago

Hello, @mtsinput

Which traefik's version are you running?

mtsinput commented 1 year ago

The error was gotten on Traefik 2.8.1

wiltonsr commented 1 year ago

This traefik's version doesn't support cachekey.

Please, test with 2.8.5.

Note that the version v2.9.4 with yaegi v0.14.3 has a bug. See #25.