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

API authentication to "create new subscriber" #1449

Closed
jcm-shove-it opened this issue Aug 12, 2023 · 3 comments
Closed

API authentication to "create new subscriber" #1449

jcm-shove-it opened this issue Aug 12, 2023 · 3 comments
Labels
enhancement New feature or request

Comments

@jcm-shove-it
Copy link

Is your feature request related to a problem? Please describe.

Currently the API documentation on adding subscribers might be misunderstood.

The example request is without authentication: https://listmonk.app/docs/apis/subscribers/#example-request_4:

curl 'http://localhost:9000/api/subscribers' -H 'Content-Type: application/json' --data '{"email":"subsriber@domain.com","name":"The Subscriber","status":"enabled","lists":[1],"attribs": {"city":"Bengaluru","projects":3,"stack":{"languages":["go","python"]}}}'

This seems correct as one can subscribe on the web form without authentication. Unfortunately, this call gives {"message":"Unauthorized"}.

On the other hand, the API doc states (https://listmonk.app/docs/apis/apis/):

API requests require BasicAuth authentication with the admin credentials.

Describe the solution you'd like

Wouldn't it make sense to allow adding subscribers without authentication? In our scenario, we need to add subscriptions from another web app. Currently I am using as a workaround a POST request found when checking the manual subscription web page: curl http://localhost:9000 -H 'application/x-www-form-urlencoded' --data 'email=email_localpart%40email_domain&nonce=&name=name&l=uuid_of_list', which is fully functional but a bit ugly.

Thanks for having a look at this, Joerg

@jcm-shove-it jcm-shove-it added the enhancement New feature or request label Aug 12, 2023
@knadh knadh closed this as completed in 32b979e Aug 13, 2023
@knadh
Copy link
Owner

knadh commented Aug 13, 2023

Ah, looks like that curl example is missing the -u param. All /api/*, except for /api/public/* calls need authentication. Just fixed it in the docs.

@porterporter
Copy link

For me, POSTing /api/public/subscription still returns 401 { message: 'Unauthorized' }. Am I missing something or is this intended behavior?

@jcm-shove-it
Copy link
Author

Ok, you updated the docs now to remove the misunderstanding, thanks. Still I am wondering why authentication is required to subscribe an email address to a list via json API while the authentication is not required to subscribe via POST of x-www-form-urlencoded?

Is there a reason this add subscription json API is not public?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants