eclecticiq / OpenTAXII

TAXII server implementation in Python from EclecticIQ
BSD 3-Clause "New" or "Revised" License
185 stars 88 forks source link

Continually getting 401 Unauthorized Errors #241

Open spershing2022 opened 1 year ago

spershing2022 commented 1 year ago

I have tried to using the latest docker image, downloading the repo and creating a docker image, and I have tried using an older version, however I cannot get past the authentication step:

docker run -d -p 9000:9000 eclecticiq/opentaxii Unable to find image 'eclecticiq/opentaxii:latest' locally latest: Pulling from eclecticiq/opentaxii 7a6db449b51b: Pull complete e238bceb2957: Pull complete b94fc7ac342a: Pull complete aa1ba22295b5: Pull complete 76b791f9be0a: Pull complete b1591e80a14c: Pull complete ae2888cd1872: Pull complete b370602749fd: Pull complete Digest: sha256:452e90c0bc95eb582a792fdd9dc389853921ebeca7bc6936435e070b65369698 Status: Downloaded newer image for eclecticiq/opentaxii:latest a60a642c41bc3045952bf95f4e6ebbf5eab85c57f183fb8671c3178000003941

curl -v -H "Content-Type: application/json" -d '{"username":"test","password":"test"}' http://localhost:9000/management/auth

Something that I noticed is that the auth.db seems to be empty:

docker container ls CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES a60a642c41bc eclecticiq/opentaxii "/entrypoint.sh /ven…" 8 minutes ago Up 8 minutes 0.0.0.0:9000->9000/tcp, :::9000->9000/tcp brave_poitras

docker exec -it a60a642c41bc /bin/bash root@a60a642c41bc:/# cd /data/ root@a60a642c41bc:/data# ls auth.db data.db root@a60a642c41bc:/data# apt-get install sqlite3 Reading package lists... Done Building dependency tree... Done Reading state information... Done Suggested packages: sqlite3-doc The following NEW packages will be installed: sqlite3 0 upgraded, 1 newly installed, 0 to remove and 0 not upgraded. Need to get 1201 kB of archives. After this operation, 3155 kB of additional disk space will be used. Get:1 http://deb.debian.org/debian bullseye/main amd64 sqlite3 amd64 3.34.1-3 [1201 kB] Fetched 1201 kB in 0s (25.5 MB/s) debconf: delaying package configuration, since apt-utils is not installed Selecting previously unselected package sqlite3. (Reading database ... 9812 files and directories currently installed.) Preparing to unpack .../sqlite3_3.34.1-3_amd64.deb ... Unpacking sqlite3 (3.34.1-3) ... Setting up sqlite3 (3.34.1-3) ... root@a60a642c41bc:/data# sqlite3 auth.db SQLite version 3.34.1 2021-01-20 14:10:07 Enter ".help" for usage hints. sqlite> .tables accounts sqlite> SELECT * FROM accounts; sqlite>

sqlite> SELECT COUNT(*) from accounts; 0

Is this the cause of the issue, or is there something else that is going on? Any steps that I am missing?

spershing2022 commented 1 year ago

What I found is that the problem is indeed the fact that the auth.db and data.db are empty. I was able to fix it by using the same procedure in this issue: https://github.com/eclecticiq/OpenTAXII/issues/127

This populated the databases in the /tmp directory in the container, and then I had to copy the database files to the /data directory. After this, I was able to get a token from the container.