sipcapture / homer-app

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

OAuth2 with github provider #485

Closed ghost closed 2 days ago

ghost commented 2 years ago

Hey, I would like to kindly ask if you could help with github provider in Homer. As there is little documentation on how to set up, I configured that this way:

            "oauth2": {
              "enable": true,
              "client_id": "{{`{{ .client_id }}`}}",
              "client_secret": "{{`{{ .client_secret }}`}}",
              "project_id": "Homer stage",
              "auth_uri": "https://github.com/login/oauth/authorize",
              "token_uri": "https://github.com/login/oauth/access_token",
              "redirect_uri": "https://{{ .Values.homer.ingress.hostname }}/api/v3/oauth2/auth",
              "service_redirect": "/api/v3/oauth2/redirect",
              "profile_url": "https://api.github.com/user",
              "provider_name": "github",
              "grant_type": "authorization_code",
              "response_type": "code",
              "scope": ["email", "openid", "profile"]
            },

However, I am getting 502 response and panic error.

echo: http: panic serving 10.100.116.249:21736: interface conversion: interface {} is nil, not string
goroutine 115 [running]:
net/http.(*conn).serve.func1(0xc000378aa0)
    /usr/local/go/src/net/http/server.go:1801 +0x147
panic(0xdbb060, 0xc000594c30)
    /usr/local/go/src/runtime/panic.go:975 +0x47a
github.com/sipcapture/homer-app/data/service.(*UserService).LoginUserUsingOauthToken(0xc0004d41c0, 0x0, 0x0, 0x0, 0x0, 0x0, 0xc0b9ae9ec96cd23a, 0x7f51a23c1, 0x16a9520, 0xc0b9aee9c96cd2aa, ...)
    /homer-app/data/service/user.go:373 +0xbd9
github.com/sipcapture/homer-app/controller/v1.(*UserController).Oauth2TokenExchange(0xc0003c2610, 0x101be80, 0xc0004ae320, 0x14ed501, 0x2)
    /homer-app/controller/v1/user.go:578 +0x2d9
github.com/labstack/echo/v4.(*Echo).add.func1(0x101be80, 0xc0004ae320, 0x1, 0x0)
    /go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/echo.go:544 +0x62
github.com/labstack/echo/v4/middleware.GzipWithConfig.func1.1(0x101be80, 0xc0004ae320, 0x0, 0x0)
    /go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/middleware/compress.go:67 +0x735
github.com/labstack/echo/v4/middleware.StaticWithConfig.func1.1(0x101be80, 0xc0004ae320, 0xff3b00, 0xc0005949c0)
    /go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/middleware/static.go:195 +0x798
main.GrafanaHeader.func1(0x101be80, 0xc0004ae320, 0xed8075, 0x1b)
    /homer-app/main.go:1821 +0x93
github.com/labstack/echo/v4/middleware.CORSWithConfig.func1.1(0x101be80, 0xc0004ae320, 0x4, 0x4)
    /go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/middleware/cors.go:186 +0x100b
github.com/labstack/echo/v4.(*Echo).ServeHTTP.func1(0x101be80, 0xc0004ae320, 0x8b9a01, 0xc0006a4400)
    /go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/echo.go:648 +0x115
github.com/labstack/echo/v4/middleware.RewriteWithConfig.func1.1(0x101be80, 0xc0004ae320, 0x1, 0x1)
    /go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/middleware/rewrite.go:72 +0x102
github.com/labstack/echo/v4.(*Echo).ServeHTTP(0xc0004b2000, 0x1004720, 0xc0003f7dc0, 0xc0000de400)
    /go/pkg/mod/github.com/labstack/echo/v4@v4.5.0/echo.go:654 +0x182
net/http.serverHandler.ServeHTTP(0xc0003f60e0, 0x1004720, 0xc0003f7dc0, 0xc0000de400)
    /usr/local/go/src/net/http/server.go:2843 +0xa3
net/http.(*conn).serve(0xc000378aa0, 0x10077e0, 0xc000369840)
    /usr/local/go/src/net/http/server.go:1925 +0x8ad
created by net/http.(*Server).Serve
    /usr/local/go/src/net/http/server.go:2969 +0x36c

Thank you for any help!

github-actions[bot] commented 2 years ago

Your report is appreciated. Please star this repository to motivate its developers! :star:

adubovikov commented 2 days ago

Please try the latest version. We did full integration for all Oauth2 provides (Okta, GitHub, Keyclock)