mail-in-a-box / mailinabox

Mail-in-a-Box helps individuals take back control of their email by defining a one-click, easy-to-deploy SMTP+everything else server: a mail server in a box.
https://mailinabox.email/
Creative Commons Zero v1.0 Universal
14.05k stars 1.44k forks source link

BUG: API with authorization by API key doesn't work #2448

Closed il2020 closed 1 month ago

il2020 commented 1 month ago

Trying to use the key from /var/lib/mailinabox/api.key:

KEY=$(cat /var/lib/mailinabox/api.key) && curl -X GET -H "Authorization: Basic $KEY" https://example.com/admin/mail/aliases

And I'm getting an error:

'ascii' codec can't decode byte 0xb0 in position 1: ordinal not in range(128)

I'm using Mail-in-a-Box v69b.

downtownallday commented 1 month ago

There is no bug. The Basic authentication scheme requires the username and password be base64 encoded.

See https://www.rfc-editor.org/rfc/rfc7617.html

You can just use curl's -u argument instead of appending the header manually. curl -u "$KEY:" https://example.com/admin/mail/aliases, or use the management/cli.py tool.

il2020 commented 1 month ago

There is no bug. The Basic authentication scheme requires the username and password be base64 encoded.

See https://www.rfc-editor.org/rfc/rfc7617.html

You can just use curl's -u argument instead of appending the header manually. curl -u "$KEY:" https://example.com/admin/mail/aliases, or use the management/cli.py tool.

Thank you. I found that solution on the forum: https://discourse.mailinabox.email/t/api-requires-2fa/7222/2 It would be great if there were instructions on how to use the API key in the admin area.