plane icon indicating copy to clipboard operation
plane copied to clipboard

[bug]: Initial part get 401 Unauthorized

Open jian0209 opened this issue 9 months ago • 2 comments

Is there an existing issue for this?

  • [X] I have searched the existing issues

Current behavior

It is smooth when i publish the app, but I stuck on getting 401 with this api "api/users/me/" Below is the backend log

[2024-05-04 07:01:41 +0000] [34] [INFO] Application startup complete.
172.18.0.12:46674 - "GET /api/instances/ HTTP/1.0" 200
172.18.0.12:45982 - "GET /api/instances/ HTTP/1.0" 200
172.18.0.12:38942 - "GET /api/configs/ HTTP/1.0" 200
WARNING 2024-05-04 07:03:13,053 log 33 139889945951032 Unauthorized: /api/users/me/
172.18.0.12:38948 - "GET /api/users/me/ HTTP/1.0" 401
172.18.0.12:59388 - "POST /api/instances/admins/sign-in/ HTTP/1.0" 200
WARNING 2024-05-04 07:03:50,173 log 33 139889945951032 Unauthorized: /api/users/me/
172.18.0.12:59404 - "GET /api/users/me/ HTTP/1.0" 401

Below is my env file

DEBUG=0
CORS_ALLOWED_ORIGINS="https://yyy.xxx.com"

POSTGRES_USER="xxx"
POSTGRES_PASSWORD="xxx"
POSTGRES_HOST="xxx"
POSTGRES_DB="xxx"
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}/${POSTGRES_DB}

REDIS_HOST="plane-redis"
REDIS_PORT="6379"
REDIS_URL="redis://${REDIS_HOST}:6379/"

FILE_SIZE_LIMIT=5242880

USE_MINIO=1

WEB_URL="https://yyy.xxx.com"

GUNICORN_WORKERS=2
SECRET_KEY="xxx"

Steps to reproduce

  1. Visit webpage at the start
  2. Go into god-mode
  3. Visit "api/users/me" Return 401 error

Environment

Production

Browser

Google Chrome

Variant

Self-hosted

Version

docker-stable

jian0209 avatar May 04 '24 07:05 jian0209

Can anyone help me here? I am stuck in setup the project, I have my own secret key, but it still getting 401 "Authentication credentials were not provided" @pushya22

jian0209 avatar May 06 '24 04:05 jian0209

I have the same issue...

infinitr0us avatar May 13 '24 00:05 infinitr0us

Same issue here ...

Foohx avatar Jun 13 '24 17:06 Foohx

Fixed for me, the SECRET_KEY environment variable was missing

Foohx avatar Jun 14 '24 07:06 Foohx

I have my secret key too, i can’t also.

jian0209 avatar Jun 14 '24 09:06 jian0209

I have my secret key too, i can’t also.

401 in this project is simply a configuration problem. :)

I use these 3 files (below) to launch plane, all in the same folder. I made some modifications to use the latest docker hub images (because cloning, setup.sh etc... are very very annoying !)

Just do a docker compose up -d in the same folder as the files and everything should work without a problem.

Once the migrations and setup are complete, you can go to http://localhost:8080

compose.yml :

services:
  web:
    image: "makeplane/plane-frontend:stable"
    container_name: web
    restart: always
    command: node web/server.js web
    depends_on:
      - api

  admin:
    image: "makeplane/plane-admin:stable"
    container_name: admin
    restart: always
    command: node admin/server.js admin
    depends_on:
      - api
      - web

  space:
    image: "makeplane/plane-space:stable"
    container_name: space
    restart: always
    command: node space/server.js space
    depends_on:
      - api
      - web

  api:
    image: "makeplane/plane-backend:stable"
    container_name: api
    restart: always
    command: ./bin/docker-entrypoint-api.sh
    env_file:
      - .env.api
    depends_on:
      - plane-db
      - plane-redis

  worker:
    image: "makeplane/plane-backend:stable"
    container_name: bgworker
    restart: always
    command: ./bin/docker-entrypoint-worker.sh
    env_file:
      - .env.api
    depends_on:
      - api
      - plane-db
      - plane-redis

  beat-worker:
    image: "makeplane/plane-backend:stable"
    container_name: beatworker
    restart: always
    command: ./bin/docker-entrypoint-beat.sh
    env_file:
      - .env.api
    depends_on:
      - api
      - plane-db
      - plane-redis

  migrator:
    image: "makeplane/plane-backend:stable"
    container_name: plane-migrator
    restart: no
    command: ./bin/docker-entrypoint-migrator.sh
    env_file:
      - .env.api
    depends_on:
      - plane-db
      - plane-redis

  plane-db:
    container_name: plane-db
    image: postgres:15.2-alpine
    restart: always
    command: postgres -c 'max_connections=1000'
    volumes:
      - pgdata:/var/lib/postgresql/data
    env_file:
      - .env
    environment:
      POSTGRES_USER: ${POSTGRES_USER}
      POSTGRES_DB: ${POSTGRES_DB}
      POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
      PGDATA: /var/lib/postgresql/data

  plane-redis:
    container_name: plane-redis
    image: redis:7.2.4-alpine
    restart: always
    volumes:
      - redisdata:/data

  plane-minio:
    container_name: plane-minio
    image: minio/minio
    restart: always
    command: server /export --console-address ":9090"
    volumes:
      - uploads:/export
    environment:
      MINIO_ROOT_USER: ${AWS_ACCESS_KEY_ID}
      MINIO_ROOT_PASSWORD: ${AWS_SECRET_ACCESS_KEY}

  # Comment this if you already have a reverse proxy running
  proxy:
    image: "makeplane/plane-proxy:stable"
    container_name: proxy
    restart: always
    ports:
      - ${NGINX_PORT}:80
    environment:
      FILE_SIZE_LIMIT: ${FILE_SIZE_LIMIT:-5242880}
      BUCKET_NAME: ${AWS_S3_BUCKET_NAME:-uploads}
    depends_on:
      - web
      - api
      - space
      - admin

volumes:
  pgdata:
  redisdata:
  uploads:

.env :

# Database Settings
POSTGRES_USER="plane"
POSTGRES_PASSWORD="plane"
POSTGRES_DB="plane"
PGDATA="/var/lib/postgresql/data"

# Redis Settings
REDIS_HOST="plane-redis"
REDIS_PORT="6379"

# AWS Settings
AWS_REGION=""
AWS_ACCESS_KEY_ID="access-key"
AWS_SECRET_ACCESS_KEY="secret-key"
AWS_S3_ENDPOINT_URL="http://plane-minio:9000"
# Changing this requires change in the nginx.conf for uploads if using minio setup
AWS_S3_BUCKET_NAME="uploads"
# Maximum file upload limit
FILE_SIZE_LIMIT=5242880

# GPT settings
OPENAI_API_BASE="https://api.openai.com/v1" # deprecated
OPENAI_API_KEY="sk-" # deprecated
GPT_ENGINE="gpt-3.5-turbo" # deprecated

# Settings related to Docker
DOCKERIZED=1  # deprecated

# set to 1 If using the pre-configured minio setup
USE_MINIO=1

# Nginx Configuration
NGINX_PORT=8080

.env.api :

# Backend
# Debug value for api server use it as 0 for production use
DEBUG=0
CORS_ALLOWED_ORIGINS="http://localhost:8080"

# Error logs
SENTRY_DSN=""
SENTRY_ENVIRONMENT="development"

# Database Settings
POSTGRES_USER="plane"
POSTGRES_PASSWORD="plane"
POSTGRES_HOST="plane-db"
POSTGRES_DB="plane"
POSTGRES_PORT=5432
DATABASE_URL=postgresql://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}


# Redis Settings
REDIS_HOST="plane-redis"
REDIS_PORT="6379"
REDIS_URL="redis://${REDIS_HOST}:6379/"

# AWS Settings
AWS_REGION=""
AWS_ACCESS_KEY_ID="access-key"
AWS_SECRET_ACCESS_KEY="secret-key"
AWS_S3_ENDPOINT_URL="http://plane-minio:9000"
# Changing this requires change in the nginx.conf for uploads if using minio setup
AWS_S3_BUCKET_NAME="uploads"
# Maximum file upload limit
FILE_SIZE_LIMIT=5242880

# Settings related to Docker
DOCKERIZED=1 # deprecated

# set to 1 If using the pre-configured minio setup
USE_MINIO=1

# Nginx Configuration
NGINX_PORT=8080

# Email redirections and minio domain settings
WEB_URL="http://localhost:8080"

# Gunicorn Workers
GUNICORN_WORKERS=2

# Base URLs
ADMIN_BASE_URL=
SPACE_BASE_URL=
APP_BASE_URL=

SECRET_KEY="MySuperSecret17000"

I think we can remove a few things in the environment files to avoid some duplication. My goal is to simply launch the platform to do some tests.

Let me know if this works for you too.

Good luck 😉

EDIT : To clean a previous install docker compose down -v

Foohx avatar Jun 17 '24 08:06 Foohx

Thank you~ I works on it

jian0209 avatar Jun 27 '24 03:06 jian0209