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

401 Unauthorized error when creating alias via web UI (works via browser extension) #163

Closed
klibansky opened this issue Aug 13, 2022 · 4 comments

Comments

@klibansky
Copy link

Behaviour

Via the Web UI I get a 401 Unauthorized error in the console, and a pop-up error message in the browser, whenever trying to create aliases, recipients, domains, usernames.

I can update my password, and generate an API token.

Via the browser extension on FireFox I can create aliases.

Any POST interaction with /api/v1/ results in a 401 error.

Steps to reproduce this issue

  1. run using the compose/env below
  2. Log in and attempt to create aliases

Expected behaviour

Aliases get created

Actual behaviour

The POST /api/v1/aliases endpoint gives a 401 error

Configuration

  • Docker version: 20.10.17, build 100c701
  • Docker compose version: 1.29.2, build 5becea4c
  • Platform: MacOS
  • System info: Darwin hostname.local 21.6.0 Darwin Kernel Version 21.6.0: Sat Jun 18 17:07:22 PDT 2022; root:xnu-8020.140.41~1/RELEASE_ARM64_T6000 arm64
  • Include all necessary configuration files : docker-compose.yml, .env, ...

anonaddy.env

TZ=Europe/Amsterdam
PUID=1000
PGID=1000

MEMORY_LIMIT=512M
UPLOAD_MAX_SIZE=50M
OPCACHE_MEM_SIZE=128
REAL_IP_FROM=0.0.0.0/32
REAL_IP_HEADER=X-Forwarded-For
LOG_IP_VAR=http_x_forwarded_for

APP_KEY=base64:IFR3zk2hgu/5m/5wWuyACVG4vurOTeQTeqY2dZGvAzs=
APP_DEBUG=true
APP_URL=http://127.0.0.1:8111

[email protected]
#ANONADDY_ADMIN_USERNAME=anonaddy
ANONADDY_ENABLE_REGISTRATION=false
ANONADDY_DOMAIN=example.com
ANONADDY_ALL_DOMAINS=example.com
ANONADDY_HOSTNAME=mail.example.com
ANONADDY_DNS_RESOLVER=1.1.1.1
ANONADDY_SECRET=alksjhfalksjdhf29384247sidfusdfafdadfadf234345tgf245g
ANONADDY_LIMIT=200
ANONADDY_BANDWIDTH_LIMIT=10737418240
ANONADDY_NEW_ALIAS_LIMIT=10
ANONADDY_ADDITIONAL_USERNAME_LIMIT=10
ANONADDY_WORDLIST_FILE=/var/www/anonaddy/config/wordlist.json

MAIL_FROM_NAME=randompete
[email protected]

POSTFIX_DEBUG=false
POSTFIX_SMTPD_TLS=false
POSTFIX_SMTP_TLS=false
POSTFIX_SMTPD_TLS_CERT_FILE=/certs/certificate.pem
POSTFIX_SMTPD_TLS_KEY_FILE=/certs/privatekey.pem

#DKIM_ENABLE=true
#DMARC_ENABLE=true

RSPAMD_ENABLE=true
RSPAMD_WEB_PASSWORD=abc

docker compose

version: "3.5"

services:
  anonaddy_db:
    image: mariadb:10.8
    container_name: anonaddy_db
    ports:
      - target: 3306
        published: 55009
        protocol: tcp
    command:
      - "mysqld"
      - "--character-set-server=utf8mb4"
      - "--collation-server=utf8mb4_unicode_ci"
    volumes:
      - "/Users/username/Documents/docker/anonaddy/db:/var/lib/mysql"
    environment:
      - "MYSQL_ALLOW_EMPTY_PASSWORD=yes"
      - "MYSQL_DATABASE"
      - "MYSQL_USER"
      - "MYSQL_PASSWORD"
    restart: always

  anonaddy_redis:
    image: redis:4.0-alpine
    container_name: anonaddy_redis
    restart: always

  anonaddy:
    image: anonaddy/anonaddy:latest
    container_name: anonaddy
    depends_on:
      - anonaddy_db
      - anonaddy_redis
    ports:
      - target: 25
        published: 25
        protocol: tcp
      - target: 8000
        published: 8111
        protocol: tcp
      - target: 11334
        published: 11334
        protocol: tcp

    volumes:
      - "/Users/username/Documents/docker/anonaddy/data:/data"
    env_file:
      - "./anonaddy.env"
    environment:
      - "DB_HOST=anonaddy_db"
      - "DB_DATABASE=${MYSQL_DATABASE}"
      - "DB_USERNAME=${MYSQL_USER}"
      - "DB_PASSWORD=${MYSQL_PASSWORD}"
      - "REDIS_HOST=anonaddy_redis"
    restart: always

Notes

  • This is just my local testing setup at the moment.
  • I had to change the mariadb version to 10.8 (from 10.5 from the example) otherwise I got a database version error.
  • Verification emails are being sent and received.
@klibansky
Copy link
Author

I solved the problem by following the steps in this issue #150 and adding the env var to the .env file:

SANCTUM_STATEFUL_DOMAINS=localhost,localhost:8111,127.0.0.1,127.0.0.1:8111

Because I use a custom port (not 8000 but 8111) I think the change @willbrowningme made perhaps doesn't work for me.

Any way, I don't mind adding the env var.

@Nicicalu
Copy link

My Anonaddy instance is behind a nginx reverse proxy. I just had to set SANCTUM_STATEFUL_DOMAINS=anonaddy.mydomain.com and it worked :-)

@klibansky
Copy link
Author

Mine also behind rev proxy.
I had to include the urls that i want anonaddy to be accessible on.
Are you saying yo can just ad any url or what I’m saying?

@Nicicalu
Copy link

Mine also behind rev proxy. I had to include the urls that i want anonaddy to be accessible on. Are you saying yo can just ad any url or what I’m saying?

Nono you're right. I just added the comment because I found the comments above a bit confusing and wanted to make it easier for anyone else reading through this issue.

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

2 participants