semaphore icon indicating copy to clipboard operation
semaphore copied to clipboard

LDAP fail to login second time

Open RyanLin1995 opened this issue 4 years ago • 9 comments

Hi,

I set up the LDAP for the semaphore and it can log in the first time. But the second time when I login the Semaphore via LDAP, it showed "Duplicate entry '' for key 'username'". I tried to drop the database and re-create it, it still shows this error. Below is the error log:

Server is running INFO[0004] user does not exist or too many entries returned INFO[0012] User with email authorized via LDAP correctly

ERRO[0016] websocket: close 1005 (no status) level=Error ERRO[0016] websocket: close sent level=Error ERRO[0016] close tcp 10.86.176.252:3000->10.86.180.166:53849: use of closed network connection level=Error INFO[0024] User with email authorized via LDAP correctly 2021/12/27 18:32:23 http: panic serving 10.86.180.166:53850: Error 1062: Duplicate entry '' for key 'username' goroutine 82 [running]: net/http.(*conn).serve.func1(0xc00017f180) /usr/local/go/src/net/http/server.go:1804 +0x153 panic(0x9985c0, 0xc00000e4e0) /usr/local/go/src/runtime/panic.go:971 +0x499 github.com/ansible-semaphore/semaphore/api.login(0x1857830, 0xc000624620, 0xc0000c3b00) /go/src/github.com/ansible-semaphore/semaphore/api/login.go:146 +0xcb3 net/http.HandlerFunc.ServeHTTP(0x17ca6d0, 0x1857830, 0xc000624620, 0xc0000c3b00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/ansible-semaphore/semaphore/api.JSONMiddleware.func1(0x1857830, 0xc000624620, 0xc0000c3b00) /go/src/github.com/ansible-semaphore/semaphore/api/router.go:25 +0x131 net/http.HandlerFunc.ServeHTTP(0xc0000a3260, 0x1857830, 0xc000624620, 0xc0000c3b00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/ansible-semaphore/semaphore/cli/cmd.runService.func1.1(0x1857830, 0xc000624620, 0xc0000c3b00) /go/src/github.com/ansible-semaphore/semaphore/cli/cmd/root.go:90 +0x122 net/http.HandlerFunc.ServeHTTP(0xc00064f650, 0x1857830, 0xc000624620, 0xc0000c3b00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/gorilla/mux.CORSMethodMiddleware.func1.1(0x1857830, 0xc000624620, 0xc0000c3b00) /go/src/github.com/ansible-semaphore/semaphore/vendor/github.com/gorilla/mux/middleware.go:51 +0xf7 net/http.HandlerFunc.ServeHTTP(0xc0000d48a0, 0x1857830, 0xc000624620, 0xc0000c3b00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/gorilla/mux.(*Router).ServeHTTP(0xc0003440c0, 0x1857830, 0xc000624620, 0xc0000c3500) /go/src/github.com/ansible-semaphore/semaphore/vendor/github.com/gorilla/mux/mux.go:212 +0xd3 github.com/gorilla/handlers.ProxyHeaders.func1(0x1857830, 0xc000624620, 0xc0000c3500) /go/src/github.com/ansible-semaphore/semaphore/vendor/github.com/gorilla/handlers/proxy_headers.go:59 +0x114 net/http.HandlerFunc.ServeHTTP(0xc0000a37d0, 0x1857830, 0xc000624620, 0xc0000c3500) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/ansible-semaphore/semaphore/cli/cmd.cropTrailingSlashMiddleware.func1(0x1857830, 0xc000624620, 0xc0000c3500) /go/src/github.com/ansible-semaphore/semaphore/cli/cmd/service.go:26 +0x97 net/http.HandlerFunc.ServeHTTP(0xc0000a37e8, 0x1857830, 0xc000624620, 0xc0000c3500) /usr/local/go/src/net/http/server.go:2049 +0x44 net/http.serverHandler.ServeHTTP(0xc000624000, 0x1857830, 0xc000624620, 0xc0000c3500) /usr/local/go/src/net/http/server.go:2867 +0xa3 net/http.(*conn).serve(0xc00017f180, 0x1859180, 0xc00006b140) /usr/local/go/src/net/http/server.go:1932 +0x8cd created by net/http.(*Server).Serve /usr/local/go/src/net/http/server.go:2993 +0x39b INFO[0024] User with email authorized via LDAP correctly 2021/12/27 18:32:23 http: panic serving 10.86.180.166:53851: Error 1062: Duplicate entry '' for key 'username' goroutine 69 [running]: net/http.(*conn).serve.func1(0xc00060a1e0) /usr/local/go/src/net/http/server.go:1804 +0x153 panic(0x9985c0, 0xc00000e588) /usr/local/go/src/runtime/panic.go:971 +0x499 github.com/ansible-semaphore/semaphore/api.login(0x1857830, 0xc000624700, 0xc0000c3d00) /go/src/github.com/ansible-semaphore/semaphore/api/login.go:146 +0xcb3 net/http.HandlerFunc.ServeHTTP(0x17ca6d0, 0x1857830, 0xc000624700, 0xc0000c3d00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/ansible-semaphore/semaphore/api.JSONMiddleware.func1(0x1857830, 0xc000624700, 0xc0000c3d00) /go/src/github.com/ansible-semaphore/semaphore/api/router.go:25 +0x131 net/http.HandlerFunc.ServeHTTP(0xc0000a33b0, 0x1857830, 0xc000624700, 0xc0000c3d00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/ansible-semaphore/semaphore/cli/cmd.runService.func1.1(0x1857830, 0xc000624700, 0xc0000c3d00) /go/src/github.com/ansible-semaphore/semaphore/cli/cmd/root.go:90 +0x122 net/http.HandlerFunc.ServeHTTP(0xc000020330, 0x1857830, 0xc000624700, 0xc0000c3d00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/gorilla/mux.CORSMethodMiddleware.func1.1(0x1857830, 0xc000624700, 0xc0000c3d00) /go/src/github.com/ansible-semaphore/semaphore/vendor/github.com/gorilla/mux/middleware.go:51 +0xf7 net/http.HandlerFunc.ServeHTTP(0xc0000d4a80, 0x1857830, 0xc000624700, 0xc0000c3d00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/gorilla/mux.(*Router).ServeHTTP(0xc0003440c0, 0x1857830, 0xc000624700, 0xc000253a00) /go/src/github.com/ansible-semaphore/semaphore/vendor/github.com/gorilla/mux/mux.go:212 +0xd3 github.com/gorilla/handlers.ProxyHeaders.func1(0x1857830, 0xc000624700, 0xc000253a00) /go/src/github.com/ansible-semaphore/semaphore/vendor/github.com/gorilla/handlers/proxy_headers.go:59 +0x114 net/http.HandlerFunc.ServeHTTP(0xc0000a37d0, 0x1857830, 0xc000624700, 0xc000253a00) /usr/local/go/src/net/http/server.go:2049 +0x44 github.com/ansible-semaphore/semaphore/cli/cmd.cropTrailingSlashMiddleware.func1(0x1857830, 0xc000624700, 0xc000253a00) /go/src/github.com/ansible-semaphore/semaphore/cli/cmd/service.go:26 +0x97 net/http.HandlerFunc.ServeHTTP(0xc0000a37e8, 0x1857830, 0xc000624700, 0xc000253a00) /usr/local/go/src/net/http/server.go:2049 +0x44 net/http.serverHandler.ServeHTTP(0xc000624000, 0x1857830, 0xc000624700, 0xc000253a00) /usr/local/go/src/net/http/server.go:2867 +0xa3 net/http.(*conn).serve(0xc00060a1e0, 0x1859180, 0xc0005dd240) /usr/local/go/src/net/http/server.go:1932 +0x8cd created by net/http.(*Server).Serve /usr/local/go/src/net/http/server.go:2993 +0x39b

RyanLin1995 avatar Dec 27 '21 10:12 RyanLin1995

What is UID and Mail of your LDAP user?

fiftin avatar Jan 23 '22 23:01 fiftin

Hi @RyanLin1995, can you help me with this bug?

fiftin avatar Jan 31 '22 19:01 fiftin

Hi Denis,

Sorry for reply late because I am in the Spring Festival holiday. Let me know what can I help for you. I will reply you at Feb 7.

Thanks and Happy Year of the Tiger! 恭喜发财!

Denis Gukov @.***> 于 2022年2月1日周二 上午3:32写道:

Hi @RyanLin1995 https://github.com/RyanLin1995, can you help me with this bug?

— Reply to this email directly, view it on GitHub https://github.com/ansible-semaphore/semaphore/issues/808#issuecomment-1026133760, or unsubscribe https://github.com/notifications/unsubscribe-auth/APAVVJZLNQ5RHM5FT7WFSO3UY3PUZANCNFSM5K2EGJPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

RyanLin1995 avatar Feb 02 '22 08:02 RyanLin1995

@RyanLin1995 , please try https://github.com/ansible-semaphore/semaphore/releases/tag/v2.8.43

fiftin avatar Feb 04 '22 11:02 fiftin

Hi Denis,

Sorry for the late reply. Seems the 2.8.43 doesn't work. Below is the error message [image: error.png] and config file settings. [image: config file.png]

Thanks!

Denis Gukov @.***> 于2022年2月4日周五 19:38写道:

@RyanLin1995 https://github.com/RyanLin1995 , please try https://github.com/ansible-semaphore/semaphore/releases/tag/v2.8.43

— Reply to this email directly, view it on GitHub https://github.com/ansible-semaphore/semaphore/issues/808#issuecomment-1029909497, or unsubscribe https://github.com/notifications/unsubscribe-auth/APAVVJ53WKB4E6WHM3UMYOTUZO3DLANCNFSM5K2EGJPA . Triage notifications on the go with GitHub Mobile for iOS https://apps.apple.com/app/apple-store/id1477376905?ct=notification-email&mt=8&pt=524675 or Android https://play.google.com/store/apps/details?id=com.github.android&referrer=utm_campaign%3Dnotification-email%26utm_medium%3Demail%26utm_source%3Dgithub.

You are receiving this because you were mentioned.Message ID: @.***>

RyanLin1995 avatar Feb 10 '22 05:02 RyanLin1995

Hi @RyanLin1995,

I can't see the image.

fiftin avatar Feb 12 '22 08:02 fiftin

@fiftin I am getting the same issue with Semaphore v2.8.53 LDAP is integrated, on first login user is getting logged-in successfully. After log-out it cannot. with following error:

INFO[0033] User with email authorized via LDAP correctly 2022/03/21 14:25:23 http: panic serving 10.128.194.237:56434: Error 1062: Duplicate entry '' for key 'user.username' goroutine 50 [running]:

In admin console, I can see something like this: 2022-03-21_13-46

And in DB, I can see this like this as external user: db

Can you please guide?

sohailasghar688 avatar Mar 21 '22 13:03 sohailasghar688

In my case, Issue is resolved by using following LDAP mappings with Semaphore v2.8.53:

   "ldap_mappings": {
            "dn": "dn",
            "mail": "mail",
            "uid": "uid",
            "cn": "cn"
    },

sohailasghar688 avatar Mar 23 '22 11:03 sohailasghar688

Hello, I'm running the version v2.8.53. With LDAP active I have the same behavior described. In my opinion, it's because the LDAP user doesn't have username value inserted in the user table. So, the first-time login is OK because it creates the record and continues. But the second time the key in 'username' doesn't want an empty value and that stops the login process. Did you notice this behavior? It block my adoption using LDAP unfortunately

luca-motterle-ICE avatar Jul 12 '22 12:07 luca-motterle-ICE

Hello, do we have have any progress on this issue? or at least any quick/dirty solution to fix until new release?

Thanks, Adrian

amazarache avatar Jan 27 '23 07:01 amazarache

Hi @amazarache Need more details by issue.

fiftin avatar Jan 27 '23 23:01 fiftin