Giter Club home page Giter Club logo

Comments (10)

azrikahar avatar azrikahar commented on June 24, 2024 3

Should I leave this open

@AnmSaiful seems like this is the same as #20485, but the actual root cause (env vars are automatically casted as numbers) are currently being tracked in #9521 so I think we can leave this one as closed 👍 fully understand your thought to help prevent others from coming across the same issue though!

from directus.

hanneskuettner avatar hanneskuettner commented on June 24, 2024

Heya!

Just to confirm on your second endpoint that you're listing, seems to be a type? You're listing :10010/auth/refresh but the response is talking about /auth/login. Also you've previously talked about :10300 and not 10010.

Any logs on your container? Any logs / info on the failed requests in your browser? Can you query the endpoints from your container host and make sure those work? Just some initial thoughts before I can try and replicate this. Mind sharing your traefik config to reproduce this?

Normally, during development we run directus with a port and a public URL like http://localhost:8055, so that shouldn't be a problem and more something with your personal setup.

from directus.

AnmSaiful avatar AnmSaiful commented on June 24, 2024

Hi @hanneskuettner ,

Thank you so much for your attention and participation.

Yes, that port was a typo, and I fixed it.

I've reinstalled the container, and the container logs are as follows:

[19:58:40.179] INFO: Initializing bootstrap...
[19:58:40.180] INFO: Database already initialized, skipping install
[19:58:40.180] INFO: Running migrations...
[19:58:40.186] INFO: Done
2024-05-14T19:58:40: PM2 log: Launching in no daemon mode
2024-05-14T19:58:40: PM2 log: App [directus:0] starting in -cluster mode-
2024-05-14T19:58:41: PM2 log: App [directus:0] online
[19:58:41.954] WARN: PostGIS isn't installed. Geometry type support will be limited.
[19:58:41.980] INFO: Server started at http://0.0.0.0:8055

I've created a cURL container within the same Docker network and executed curl -L http://{container-name}:8055, which returns the expected HTML.

And when I execute curl -L http://{container-name}:8055/auth/refresh and curl -L http://{container-name}:8055/auth/login, both return the same JSON output shared in the first comment.

So, it is not the port issue.

During the first load of the page (admin/login), the browser (Chrome) console looks like below (screenshot):

Screenshot 2024-05-15 at 02 25 18

Please let me know if you need more information on the investigation and debugging.

from directus.

hanneskuettner avatar hanneskuettner commented on June 24, 2024

The curl errors you're seeing are because both endpoints are POST endpoints, rather than GET, which is what you're requesting them with.

Do you have any custom hooks or flows that hook into the login / refresh logic?
Can you share the result of the /auth/refresh call, that is being returned by the server? Since it is a 400 there should be some info in there on what is failing.

And again, can you share (a redacted) version of your proxy config, because as it is I can't reproduce this error on my end.

from directus.

AnmSaiful avatar AnmSaiful commented on June 24, 2024

@hanneskuettner, just so you know, I created a separate service to examine the issue more closely.

I started with the following Docker Compose entry, and it worked:

services:
  test-cms:
    container_name: test-cms
    image: directus/directus:10.11.0
    restart: always

    environment:
      ADMIN_EMAIL: [email protected]
      ADMIN_PASSWORD: x123456
      SECRET: x123456
      DB_CLIENT: postgres
      DB_HOST: ${DB_HOST}
      DB_PORT: 5432
      DB_USER: ${DB_USERNAME}
      DB_PASSWORD: ${DB_PASSWORD}
      DB_DATABASE: test
      PUBLIC_URL: http://localhost:10300

    ports:
      - "10300:8055"

    profiles:
      - test

Afterwards, I integrated Traefik, and it also worked:

services:
  test-cms:
    container_name: test-cms
    image: directus/directus:10.11.0
    restart: always

    environment:
      ADMIN_EMAIL: [email protected]
      ADMIN_PASSWORD: x123456
      SECRET: x123456
      DB_CLIENT: postgres
      DB_HOST: ${DB_HOST}
      DB_PORT: 5432
      DB_USER: ${DB_USERNAME}
      DB_PASSWORD: ${DB_PASSWORD}
      DB_DATABASE: test
      PUBLIC_URL: http://${CMS_HOST}:${CMS_PORT}

    profiles:
      - test

    labels:
      - traefik.enable=true
      - traefik.http.routers.test-cms.rule=Host(`${CMS_HOST}`)
      - traefik.http.services.test-cms.loadbalancer.server.port=8055

I'm working on the original service (similar to the test service) to determine why that error is being raised.

I'll keep you posted here.

from directus.

hanneskuettner avatar hanneskuettner commented on June 24, 2024

So I'm going to close this for now, as it seems unrelated to Directus, and more of a setup thing. But if it turns out to be an actual problem of Directus, please comment below and I'll happily reopen this issue!

from directus.

AnmSaiful avatar AnmSaiful commented on June 24, 2024

@hanneskuettner I can see the following error in the container logs:

[10:55:15.388] ERROR: secretOrPrivateKey is not valid key material
    err: {
      "type": "Error",
      "message": "secretOrPrivateKey is not valid key material",
      "stack":
          Error: secretOrPrivateKey is not valid key material
              at module.exports [as sign] (/directus/node_modules/.pnpm/[email protected]/node_modules/jsonwebtoken/sign.js:121:24)
              at AuthenticationService.login (file:///directus/node_modules/.pnpm/@directus+api@file+api_@[email protected]_@[email protected]_@types+no_odrjvwlnfqlgyznoalys6xyvne/node_modules/@directus/api/dist/services/authentication.js:163:33)
              at async file:///directus/node_modules/.pnpm/@directus+api@file+api_@[email protected]_@[email protected]_@types+no_odrjvwlnfqlgyznoalys6xyvne/node_modules/@directus/api/dist/auth/drivers/local.js:70:56
      "extensions": {
        "stack":
            Error: secretOrPrivateKey is not valid key material
                at module.exports [as sign] (/directus/node_modules/.pnpm/[email protected]/node_modules/jsonwebtoken/sign.js:121:24)
                at AuthenticationService.login (file:///directus/node_modules/.pnpm/@directus+api@file+api_@[email protected]_@[email protected]_@types+no_odrjvwlnfqlgyznoalys6xyvne/node_modules/@directus/api/dist/services/authentication.js:163:33)
                at async file:///directus/node_modules/.pnpm/@directus+api@file+api_@[email protected]_@[email protected]_@types+no_odrjvwlnfqlgyznoalys6xyvne/node_modules/@directus/api/dist/auth/drivers/local.js:70:56
      }
    }

from directus.

AnmSaiful avatar AnmSaiful commented on June 24, 2024

@hanneskuettner , finally, I was able to figure out the issue.

I was using a secret key that contained only numbers. When I added an alphanumeric letter, it worked.

Is it expected to work like this?

from directus.

hanneskuettner avatar hanneskuettner commented on June 24, 2024

Glad you're able to solve it! That probably has something to do with the way we parse environment variables.

Also, one note for future reference. Please refrain from tagging any core maintainers, as this just generates additional noise for us. Thank you! :)

from directus.

AnmSaiful avatar AnmSaiful commented on June 24, 2024

That's no problem. I'll remember this in the future. Thank you so much for your help.

Should I leave this open, or do you want to keep the restriction of using the KEY config? If so, I recommend mentioning this in the config doc so that it will help others prevent themselves from going through the same experience, especially during the development.

from directus.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.