sipcapture / homer-app

HOMER 7.x Front-End and API Server
http://sipcapture.io
GNU Affero General Public License v3.0
204 stars 81 forks source link

Gitlab OAuth issue #513

Closed mehdithreem closed 1 year ago

mehdithreem commented 1 year ago

Hi there,

I encountered an issue while setting up OAuth2 login with Gitlab as the provider in Homer. After being redirected from Gitlab, Homer returns a 502 error. It appears that Homer assumes the user ID returned in the user details API is a string (referencing this code: here), but Gitlab's user ID is an integer.

Here is the error from the Homer logs:

echo: http: panic serving 10.0.8.8:50168: interface conversion: interface {} is float64, not string
goroutine 22 [running]:
net/http.(*conn).serve.func1()
        /usr/local/go/src/net/http/server.go:1850 +0xbf
panic({0xc5cd80, 0xc000632b40})
        /usr/local/go/src/runtime/panic.go:890 +0x262
github.com/sipcapture/homer-app/data/service.(*UserService).LoginUserUsingOauthToken(_, {{0x0, 0x0}, {0x0, 0x0, 0x0}, {0xc10719dc285eaa20, 0x25f487cc7, 0x15302e0}, {0xc1071a27285eaa67, ...}, ...})
        /homer-app/data/service/user.go:397 +0x7f4
github.com/sipcapture/homer-app/controller/v1.(*UserController).Oauth2TokenExchange(0xc00009d160, {0xeb9168, 0xc00046d7c0})
        /homer-app/controller/v1/user.go:615 +0x29a
github.com/labstack/echo/v4.(*Echo).add.func1({0xeb9168, 0xc00046d7c0})
        /go/pkg/mod/github.com/labstack/echo/v4@v4.9.0/echo.go:536 +0x51
github.com/labstack/echo/v4/middleware.GzipWithConfig.func1.1({0xeb9168, 0xc00046d7c0})
        /go/pkg/mod/github.com/labstack/echo/v4@v4.9.0/middleware/compress.go:68 +0x528
github.com/labstack/echo/v4/middleware.StaticWithConfig.func1.1({0xeb9168, 0xc00046d7c0})
        /go/pkg/mod/github.com/labstack/echo/v4@v4.9.0/middleware/static.go:196 +0x32d
main.GrafanaHeader.func1({0xeb9168, 0xc00046d7c0})
        /homer-app/main.go:1892 +0x187
github.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1({0xeb9168, 0xc00046d7c0})
        /go/pkg/mod/github.com/labstack/echo/v4@v4.9.0/middleware/cors.go:207 +0x8c9
github.com/labstack/echo/v4.(*Echo).ServeHTTP.func1({0xeb9168, 0xc00046d7c0})
        /go/pkg/mod/github.com/labstack/echo/v4@v4.9.0/echo.go:640 +0x132
github.com/labstack/echo/v4/middleware.RewriteWithConfig.func1.1({0xeb9168, 0xc00046d7c0})
        /go/pkg/mod/github.com/labstack/echo/v4@v4.9.0/middleware/rewrite.go:72 +0xa8
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc000434900, {0xeaa900?, 0xc0006500e0}, 0xc0003fc500)
        /go/pkg/mod/github.com/labstack/echo/v4@v4.9.0/echo.go:646 +0x3d1
net/http.serverHandler.ServeHTTP({0xea7de0?}, {0xeaa900, 0xc0006500e0}, 0xc0003fc500)
        /usr/local/go/src/net/http/server.go:2947 +0x30c
net/http.(*conn).serve(0xc0003f8000, {0xeab020, 0xc0003e2a50})
        /usr/local/go/src/net/http/server.go:1991 +0x607
created by net/http.(*Server).Serve
        /usr/local/go/src/net/http/server.go:3102 +0x4db
mehdithreem commented 1 year ago

Sorry, I have been using the wrong endpoint for user profile (the correct one is oauth/userinfo).