Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Janus crashes on hot-reload when oauth is not configured #395

Open
DineshReddyK opened this issue Apr 23, 2019 · 1 comment
Open

Janus crashes on hot-reload when oauth is not configured #395

DineshReddyK opened this issue Apr 23, 2019 · 1 comment

Comments

@DineshReddyK
Copy link

DineshReddyK commented Apr 23, 2019

Janus daemon is crashing on hot reload when the /etc/janus/auth directory is missing.
That seems to be because, on startup, repo is not built if auth directory is missing.
and on reload, the repo is used without any 'nil' checks.

Apr 23 12:48:04 mn-0 janus[17411]: time="2019-04-23T12:48:04+03:00" level=warning msg="an error occurred when an event was triggered" error="Could not create a file based repository for the oauth servers: open /etc/janus/auth: no such file or directory" event_name=startup
...
...

Apr 23 12:35:58 mn-0 janus[10631]: time="2019-04-23T12:35:58+03:00" level=debug msg="Registering a route" listen_path=/example1
Apr 23 12:35:58 mn-0 janus[10631]: time="2019-04-23T12:35:58+03:00" level=debug msg="Registering a route" listen_path="/example1/*"
Apr 23 12:35:58 mn-0 janus[10631]: time="2019-04-23T12:35:58+03:00" level=debug msg="API registered" api_name=example1
Apr 23 12:35:58 mn-0 janus[10631]: time="2019-04-23T12:35:58+03:00" level=debug msg="Event triggered" event_name=reload
Apr 23 12:35:58 mn-0 janus[10631]: panic: runtime error: invalid memory address or nil pointer dereference
Apr 23 12:35:58 mn-0 janus[10631]: [signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa72f55]
Apr 23 12:35:58 mn-0 janus[10631]: goroutine 14 [running]:
Apr 23 12:35:58 mn-0 janus[10631]: github.com/hellofresh/janus/pkg/plugin/oauth2.(*FileSystemRepository).FindAll(0x0, 0xc0002765f0, 0xc00009e0a0, 0xc0001f4c90, 0xbf27d4ff8ab85f54, 0x1238f17533)
Apr 23 12:35:58 mn-0 janus[10631]:         <autogenerated>:1 +0x5
Apr 23 12:35:58 mn-0 janus[10631]: github.com/hellofresh/janus/pkg/plugin/oauth2.(*OAuthLoader).getOAuthServers(0x0, 0xe5cc00, 0x0, 0xc00009e0a0, 0xc0001f4c90, 0x0)
Apr 23 12:35:58 mn-0 janus[10631]:         /root/containerfolder/src/github.com/hellofresh/janus/pkg/plugin/oauth2/loader.go:80 +0x49
Apr 23 12:35:58 mn-0 janus[10631]: github.com/hellofresh/janus/pkg/plugin/oauth2.(*OAuthLoader).LoadDefinitions(0x0, 0xe5cc00, 0x0)
Apr 23 12:35:58 mn-0 janus[10631]:         /root/containerfolder/src/github.com/hellofresh/janus/pkg/plugin/oauth2/loader.go:25 +0x3f
Apr 23 12:35:58 mn-0 janus[10631]: github.com/hellofresh/janus/pkg/plugin/oauth2.onReload(0xc34b20, 0xc000272420, 0xd2f370, 0x6)
Apr 23 12:35:58 mn-0 janus[10631]:         /root/containerfolder/src/github.com/hellofresh/janus/pkg/plugin/oauth2/setup.go:60 +0x5a
Apr 23 12:35:58 mn-0 janus[10631]: github.com/hellofresh/janus/pkg/plugin.EmitEvent(0xd2f370, 0x6, 0xc34b20, 0xc000272420, 0x0, 0x0)
Apr 23 12:35:58 mn-0 janus[10631]:         /root/containerfolder/src/github.com/hellofresh/janus/pkg/plugin/plugin.go:99 +0x177
Apr 23 12:35:58 mn-0 janus[10631]: github.com/hellofresh/janus/pkg/server.(*Server).handleEvent(0xc000122770, 0xc000269f40)
Apr 23 12:35:58 mn-0 janus[10631]:         /root/containerfolder/src/github.com/hellofresh/janus/pkg/server/server.go:352 +0x14c
Apr 23 12:35:58 mn-0 janus[10631]: github.com/hellofresh/janus/pkg/server.(*Server).listenProviders(0xc000122770, 0xc000092360)
Apr 23 12:35:58 mn-0 janus[10631]:         /root/containerfolder/src/github.com/hellofresh/janus/pkg/server/server.go:236 +0x161
Apr 23 12:35:58 mn-0 janus[10631]: created by github.com/hellofresh/janus/pkg/server.(*Server).StartWithContext
Apr 23 12:35:58 mn-0 janus[10631]:         /root/containerfolder/src/github.com/hellofresh/janus/pkg/server/server.go:92 +0x295

Reproduction Steps:

  1. start janus without the auth directory (/etc/janus/auth by default)
  2. modify the api definition json file
  3. on hot reload, janus will crash

Expected behavior:

Janus should not crash

Observed behavior:

Janus crash

Janus version: master
OS and version: fedora

@DineshReddyK DineshReddyK changed the title Janus crash on hot reload when oath is not configrued Janus crash on hot-reload when oath is not configrued Apr 23, 2019
@s4nji s4nji changed the title Janus crash on hot-reload when oath is not configrued Janus crashes on hot-reload when oauth is not configured May 3, 2019
@WillianBR
Copy link

I Have Taken the word of DineshReddyK and s4nji about the OAUTH.

But my case is:

A close friend requested me to set up Janus for his Intranet, so he can set services on LAN on a easy way (Ansible/Docker). He'll not use OAUTH (github, FB, etc.).

How I can set up the janus.toml configuration, to use only BASIC AUTH?

users = {admin = "JF2CO4ZAM5XW6ZBAMVXG65LHNAQHI3ZAORUGS4ZAMZXWY2YK"}

The error is the same:

CLIENT:
$ curl -s -X "POST" http://127.0.0.1:10081/apis -H "Content-Type: application/json" -H "Authorization:Bearer $(cat .access_token)" -d @example.json

JANUS SERVER:

# ./janus_v4.0.0_linux_amd64 start
INFO[0000] Janus starting...                             version=4.0.0
[StatsGo] 2021/12/14 17:09:12 Stats counter incremented metric=app.init.ldapserver1.janus__v4_0_0__linux__amd64
[StatsGo] 2021/12/14 17:09:12 Stats counter incremented metric=total.app
{"level":"info","msg":"Invalid or no stats exporter was specified","stats.exporter":"","time":"2021-12-14T17:09:12-03:00"}
{"level":"info","msg":"Invalid or no tracing exporter was specified","time":"2021-12-14T17:09:12-03:00","tracing.exporter":""}
{"level":"info","msg":"Janus Admin API starting...","time":"2021-12-14T17:09:12-03:00"}
{"error":"could not create a file based repository for the oauth servers: open /etc/janus/auth: no such file or directory","event_name":"startup","level":"warning","msg":"an error occurred when an event was triggered","time":"2021-12-14T17:09:12-03:00"}
{"level":"info","msg":"Janus started","time":"2021-12-14T17:09:12-03:00"}
{"address":":10080","level":"info","msg":"Certificate and certificate key were not found, defaulting to HTTP","time":"2021-12-14T17:09:12-03:00"}
{"level":"info","msg":"Janus Admin API started","time":"2021-12-14T17:09:12-03:00"}
{"address":":10081","level":"info","msg":"Certificate and certificate key were not found, defaulting to HTTP","time":"2021-12-14T17:09:12-03:00"}
{"code":201,"duration":0,"duration-fmt":"784.844µs","host":"127.0.0.1:10081","level":"info","method":"POST","msg":"Completed handling request","referer":"","remote-addr":"127.0.0.1:39426","request":"/apis","request-id":"","time":"2021-12-14T17:09:17-03:00","user-agent":"curl/7.60.0"}
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x0 pc=0xa65905]

goroutine 31 [running]:
github.com/hellofresh/janus/pkg/plugin/oauth2.(*FileSystemRepository).FindAll(0x0, 0x0, 0x0, 0x0, 0x0, 0x0)
        <autogenerated>:1 +0x5
github.com/hellofresh/janus/pkg/plugin/oauth2.(*OAuthLoader).getOAuthServers(0x0, 0xe533e0, 0x0, 0x0, 0x0, 0x0)
        /home/runner/work/janus/janus/pkg/plugin/oauth2/loader.go:80 +0x49
github.com/hellofresh/janus/pkg/plugin/oauth2.(*OAuthLoader).LoadDefinitions(0x0, 0xe533e0, 0x0)
        /home/runner/work/janus/janus/pkg/plugin/oauth2/loader.go:25 +0x3f
github.com/hellofresh/janus/pkg/plugin/oauth2.onReload(0xc1f420, 0xc000469e80, 0xd1cdbd, 0x6)
        /home/runner/work/janus/janus/pkg/plugin/oauth2/setup.go:61 +0x5a
github.com/hellofresh/janus/pkg/plugin.EmitEvent(0xd1cdbd, 0x6, 0xc1f420, 0xc000469e80, 0x1, 0x60)
        /home/runner/work/janus/janus/pkg/plugin/plugin.go:99 +0x176
github.com/hellofresh/janus/pkg/server.(*Server).handleEvent(0xc0000cd500, 0xc00000df20)
        /home/runner/work/janus/janus/pkg/server/server.go:338 +0x120
github.com/hellofresh/janus/pkg/server.(*Server).startProvider.func1(0xc0000cd500, 0xe518a0, 0xc000115000)
        /home/runner/work/janus/janus/pkg/server/server.go:204 +0x1c3
created by github.com/hellofresh/janus/pkg/server.(*Server).startProvider
        /home/runner/work/janus/janus/pkg/server/server.go:189 +0x2e2

The janus.toml file is:

 port = 10080
[web]
port = 10081
  [web.credentials]
    algorithm = "HS256"
    secret = "secret key"
    timeout = "1h"
    [web.credentials.github]
    organizations = ["JBOffice"]
    teams = {yourOrganization = "devs"}
    users = {admin = "JF2CO4ZAM5XW6ZBAMVXG65LHNAQHI3ZAORUGS4ZAMZXWY2YK"}
[database]
    dsn = "file:///etc/janus"

Despite the fact of I'm testing on a OpenSuse Linux, but the final server will be a Windows Server without MongoDB. So any help about set the dsn to a Windows file system!

My guess is something like:
dsn = "file:///C:/etc/janus"

Does anybody can give a guidece?

-------x-------x

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants