1 (edited by ajames 2019-06-17 18:49:04)

Topic: API login woes

==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release):  0.9.9 MYSQL edition
- Deployed with iRedMail Easy or the downloadable installer? Installer
- Linux/BSD distribution name and version: Ubuntu 18.04
- Store mail accounts in which backend (LDAP/MySQL/PGSQL):  MySQL
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? True
====

I am having trouble getting even basic API queries to work (Curl). The cookie is created, but any attempts even with a GET for domain profile just dumps out the Login page requesting login.


curl -X POST -c cookie.txt -d "username=postmaster@domain.com&password=my@password@here" https://mail.server.net/iredadmin/api/login

cookie.txt

# Netscape HTTP Cookie File
# https://curl.haxx.se/docs/http-cookies.html
# This file was generated by libcurl! Edit at your own risk.


#HttpOnly_mail.server.net        FALSE   /iredadmin/     FALSE   0       iRedAdmin-Pro-mysql     2519460ba56e26b3691ced137312f1195abce6dd

Attempt to GET domain profile using above cookie:

curl -X GET -i -b cookie.txt https://mail.server.net/iredadmin/api/domain/example.com

Just dumps out the HTML of the login page

Attempt to POST create a new domain:

curl -X POST -i -b cookie.txt -d "cn=Example" https://mail.server.net/iredadmin/api/domain/example2.com
HTTP/1.1 303 See Other
Server: nginx
Date: Mon, 17 Jun 2019 10:41:38 GMT
Content-Type: text/html
Transfer-Encoding: chunked
Connection: keep-alive
Location: https://mail.server.net/iredadmin/login?msg=INVALID_CREDENTIALS
Set-Cookie: iRedAdmin-Pro-mysql=0fd4509b74c0f7b6fb6b0a0d52fdef6a93abd4a0; Path=/iredadmin/; httponly
Strict-Transport-Security: max-age=31536000

Any idea where I am going wrong with the authenticating with the API?

----

Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.

2

Re: API login woes

Did you enable RESTful API in iRedAdmin-Pro config file, and restart the "iredadmin" service?

3

Re: API login woes

Apologies, I had restarted nginx and uwsgi thinking that is all that was needed. Have now done a 'service iredadmin restart' and have just had a successful POST to the API.

{"_success": true}

Many thanks and sorry for wasting your time.

Regards,

Alun