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

[BUG] unauthorized access #241

Closed
henfri opened this issue May 10, 2022 · 9 comments · Fixed by #245
Closed

[BUG] unauthorized access #241

henfri opened this issue May 10, 2022 · 9 comments · Fixed by #245
Labels
bug Something isn't working waiting for response

Comments

@henfri
Copy link
Contributor

henfri commented May 10, 2022

Describe the bug
When starting the scrutiny container for the 2nd time (1st time was ok), I get this error:

scrutiny    | Start the scrutiny server
scrutiny    | [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
scrutiny    |  - using env:     export GIN_MODE=release
scrutiny    |  - using code:    gin.SetMode(gin.ReleaseMode)
scrutiny    |
scrutiny    | time="2022-05-10T19:34:49Z" level=info msg="Trying to connect to scrutiny sqlite db: /opt/scrutiny/config/scrutiny.db\n"
scrutiny    | time="2022-05-10T19:34:49Z" level=info msg="Successfully connected to scrutiny sqlite db: /opt/scrutiny/config/scrutiny.db\n"
scrutiny    | ts=2022-05-10T19:34:49.153391Z lvl=info msg=Unauthorized log_id=0aNsJ9F0000 error="authorization not found"
scrutiny    | panic: unauthorized: unauthorized access
scrutiny    |
scrutiny    | goroutine 1 [running]:
scrutiny    | github.com/analogj/scrutiny/webapp/backend/pkg/web/middleware.RepositoryMiddleware(0x129f900, 0xc000010d10, 0x12a4ae0, 0xc000344690, 0x129f980)
scrutiny    |   /go/src/github.com/analogj/scrutiny/webapp/backend/pkg/web/middleware/repository.go:14 +0xe6
scrutiny    | github.com/analogj/scrutiny/webapp/backend/pkg/web.(*AppEngine).Setup(0xc000337080, 0x12a4ae0, 0xc000344690, 0x14)
scrutiny    |   /go/src/github.com/analogj/scrutiny/webapp/backend/pkg/web/server.go:26 +0xd8
scrutiny    | github.com/analogj/scrutiny/webapp/backend/pkg/web.(*AppEngine).Start(0xc000337080, 0x0, 0x0)
scrutiny    |   /go/src/github.com/analogj/scrutiny/webapp/backend/pkg/web/server.go:97 +0x234
scrutiny    | main.main.func2(0xc00034c100, 0x4, 0x6)
scrutiny    |   /go/src/github.com/analogj/scrutiny/webapp/backend/cmd/scrutiny/scrutiny.go:112 +0x198
scrutiny    | github.com/urfave/cli/v2.(*Command).Run(0xc000347560, 0xc00029ff80, 0x0, 0x0)
scrutiny    |   /go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/command.go:164 +0x4e0
scrutiny    | github.com/urfave/cli/v2.(*App).RunContext(0xc00027c300, 0x128e800, 0xc000036030, 0xc00000e080, 0x2, 0x2, 0x0, 0x0)
scrutiny    |   /go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/app.go:306 +0x814
scrutiny    | github.com/urfave/cli/v2.(*App).Run(...)
scrutiny    |   /go/pkg/mod/github.com/urfave/cli/v2@v2.2.0/app.go:215
scrutiny    | main.main()
scrutiny    |   /go/src/github.com/analogj/scrutiny/webapp/backend/cmd/scrutiny/scrutiny.go:137 +0x65a

Expected behavior
No "unauthorized access" error

Screenshots
N/A

Log Files
See above

version: '3.5'

services:
  scrutiny:
    container_name: scrutiny
    image: ghcr.io/analogj/scrutiny:master-omnibus
    restart: unless-stopped
    cap_add:
      - SYS_RAWIO
    ports:
      - "89:8080"
    volumes:
      - /run/udev:/run/udev:ro
      - /srv/Daten/dockerconfig/scrutiny/config:/opt/scrutiny/config
      - /srv/Daten/dockerconfig/scrutiny/influxdb:/var/lib/influxdb2
    devices:
      - "/dev/sda"
      - "/dev/sdb"
      - "/dev/sdc"
      - "/dev/sdd"
      - "/dev/sde"
      - "/dev/sdf"
      - "/dev/sdg"
      - "/dev/sdh"

What could be the reason for this?

Best regards,
Hendrik

@henfri henfri added the bug Something isn't working label May 10, 2022
@AnalogJ
Copy link
Owner

AnalogJ commented May 10, 2022

can you confirm that your /srv/Daten/dockerconfig/scrutiny/config directory contains a scrutiny.yaml file?
Does the file have a web.influxdb.token key?

@shamoon
Copy link
Contributor

shamoon commented May 10, 2022

I got this bug when try to restore from a backup (I just duplicated /config and /influxdb dirs), my yaml does contain the token, not sure next best move, thank you

@AnalogJ
Copy link
Owner

AnalogJ commented May 10, 2022

can you shut down the service, then edit the docker-compose.yaml file to add a new port mapping:

version: '3.5'

services:
  scrutiny:
    container_name: scrutiny
    image: ghcr.io/analogj/scrutiny:master-omnibus
    restart: unless-stopped
    cap_add:
      - SYS_RAWIO
    ports:
      - "89:8080"
      - "8086:8086"
    volumes:
      - /run/udev:/run/udev:ro
      - /srv/Daten/dockerconfig/scrutiny/config:/opt/scrutiny/config
      - /srv/Daten/dockerconfig/scrutiny/influxdb:/var/lib/influxdb2
    devices:
      - "/dev/sda"
      - "/dev/sdb"
      - "/dev/sdc"
      - "/dev/sdd"
      - "/dev/sde"
      - "/dev/sdf"
      - "/dev/sdg"
      - "/dev/sdh"

when you visit http://server_name_here:8086 you should see a login page for the InfluxDB. Login with admin and password12345 as the username and password.
Then you can view the admin token and verify that it matches the one in your config file:

image

@shamoon
Copy link
Contributor

shamoon commented May 10, 2022

Actually it looks like influxdb is getting reset every time I recreate the container, when I load the web interface every time it wants to onboard me, if I set it up with details as above admin / password12345 etc it still gets lost next time around. I have a similar mapping as op in my compose:
/home/docker/scrutiny/influxdb:/var/lib/influxdb2 but that directory always seems to stay empty, hmm...

The above instructions do work for me BTW, just temporarily...

@shamoon
Copy link
Contributor

shamoon commented May 10, 2022

Aha! I think the compose needs to be
/opt/scrutiny/influxdb not /var/lib/influxdb2 since thats whats in

ENV INFLUXD_CONFIG_PATH=/opt/scrutiny/influxdb

Seems to sort this issue for me, thanks!

@henfri
Copy link
Contributor Author

henfri commented May 11, 2022

Thanks, that fixed it for me.

The docker-compose file needs an update.

Best regards,
Hendrik

henfri added a commit to henfri/scrutiny that referenced this issue May 11, 2022
@AnalogJ
Copy link
Owner

AnalogJ commented May 12, 2022

for anyone looking at this issue in the future, I've added a quick troubleshooting guide for influxdb: https://github.com/AnalogJ/scrutiny/blob/master/docs/TROUBLESHOOTING_INFLUXDB.md

@henfri
Copy link
Contributor Author

henfri commented May 13, 2022

Hello,

thanks for that!
To ensure that all data is correctly stored, you must also persist the InfluxDB database directory - /opt/scrutiny/influxdb (for Docker omnibus image) - /var/lib/influxdb2 (for vanilla Influxdb image influxdb:2.2)

I do not know what vanilla and omnibus are. It would be good to harmonize the directorystructure amonst them - unless one is "legacy".

Greetings,
Hendrik

@AnalogJ
Copy link
Owner

AnalogJ commented May 15, 2022

omnibus is a flavor of the Scrutiny docker image that contains all 3 components: influxdb, webserver/api and collector.

by vanilla InfluxDB, I mean the official influxDB maintained docker image influxdb:2.2.

I'll work on the wording in that document.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working waiting for response
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants