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

Continually getting 401 Unauthorized Errors #241

Open
spershing2022 opened this issue Sep 15, 2022 · 1 comment
Open

Continually getting 401 Unauthorized Errors #241

spershing2022 opened this issue Sep 15, 2022 · 1 comment

Comments

@spershing2022
Copy link

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

  • Trying 127.0.0.1:9000...
  • Connected to localhost (127.0.0.1) port 9000 (#0)

POST /management/auth HTTP/1.1
Host: localhost:9000
User-Agent: curl/7.79.1
Accept: /
Content-Type: application/json
Content-Length: 37

  • Mark bundle as not supporting multiuse
    < HTTP/1.1 401 UNAUTHORIZED
    < Server: gunicorn/20.0.4
    < Date: Thu, 15 Sep 2022 22:19:37 GMT
    < Connection: close
    < Content-Type: text/html; charset=utf-8
    < Content-Length: 317
    <
    <!doctype html>
<title>401 Unauthorized</title>

Unauthorized

The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.

* Closing connection 0 curl -v -H "Content-Type: application/json" -d '{"username":"admin","password":"admin"}' http://localhost:9000/management/auth * Trying 127.0.0.1:9000... * Connected to localhost (127.0.0.1) port 9000 (#0) > POST /management/auth HTTP/1.1 > Host: localhost:9000 > User-Agent: curl/7.79.1 > Accept: */* > Content-Type: application/json > Content-Length: 39 > * Mark bundle as not supporting multiuse < HTTP/1.1 401 UNAUTHORIZED < Server: gunicorn/20.0.4 < Date: Thu, 15 Sep 2022 22:25:13 GMT < Connection: close < Content-Type: text/html; charset=utf-8 < Content-Length: 317 < <title>401 Unauthorized</title>

Unauthorized

The server could not verify that you are authorized to access the URL requested. You either supplied the wrong credentials (e.g. a bad password), or your browser doesn't understand how to supply the credentials required.

* Closing connection 0

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
Copy link
Author

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: #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.

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

1 participant