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 registration is not allowed, but it is reported as allowed #6314

Closed
caspermeijn opened this issue Feb 17, 2023 · 2 comments · Fixed by #6315
Closed

API registration is not allowed, but it is reported as allowed #6314

caspermeijn opened this issue Feb 17, 2023 · 2 comments · Fixed by #6315
Milestone

Comments

@caspermeijn
Copy link
Contributor

Environment

  • Version: Git master c0cb7ef
  • Installation: Using instructions in .github/CONTRIBUTING.md
  • PHP version: 7.4
  • OS: Linux
  • Database: SQLite
  • Parameters:
My app/config/parameters.yml is:
parameters:
  database_driver: pdo_sqlite
  database_driver_class: ~
  database_host: 127.0.0.1
  database_port: ~
  database_name: symfony
  database_user: root
  database_password: ~
  database_path: '%kernel.project_dir%/data/db/wallabag.sqlite'
  database_table_prefix: wallabag_
  database_socket: null
  database_charset: utf8

  domain_name: http://localhost:8000
  server_name: "Your wallabag instance"

  mailer_dsn: "smtp://127.0.0.1"

  locale: en

  # A secret key that's used to generate certain security-related tokens
  secret: ch4n63m31fy0uc4n

  # two factor stuff
  twofactor_auth: true
  twofactor_sender: no-reply@wallabag.org

  # fosuser stuff
  fosuser_registration: true
  fosuser_confirmation: true

  fos_oauth_server_access_token_lifetime: 3600
  fos_oauth_server_refresh_token_lifetime: 1209600

  from_email: wallabag@example.com

  rss_limit: 50

  # RabbitMQ processing
  rabbitmq_host: localhost
  rabbitmq_port: 5672
  rabbitmq_user: guest
  rabbitmq_password: guest
  rabbitmq_prefetch_count: 10

  # Redis processing
  redis_scheme: tcp
  redis_host: redis
  redis_port: 6379
  redis_path: ~
  redis_password: ~

  # Sentry
  sentry_dsn: ~

  session_handler: ~

What steps will reproduce the bug?

curl -X 'GET' \
  'http://127.0.0.1:8000/api/info' \
  -H 'accept: application/json'

returns: "allowed_registration": true

But

curl -X 'PUT' \
  'http://127.0.0.1:8000/api/user' \
  -H 'accept: */*' \
  -H 'Content-Type: application/json' \
  -d '{
  "username": "string",
  "password": "string",
  "email": "string",
  "client_name": "string"
}'

returns: "error": "Server doesn't allow registrations"

These contradict each other. I expect that registration via API is possible when the API indicates that registration is allowed.

Configuration options

I found there are two configuration options:

  1. fosuser_registration, which indicates whether registration is allowed at all
  2. api_user_registration, which indicates whether registration is allowed via the API

Why is there different behavior between frontend registration and API registration?

@j0k3r
Copy link
Member

j0k3r commented Feb 17, 2023

I can't properly remember but I know it was done on purpose: #3177
Maybe we should adjust the response from WallabagRestController to take care of both configuration

'allowed_registration' => $this->getParameter('fosuser_registration'),

@caspermeijn
Copy link
Contributor Author

I can't properly remember but I know it was done on purpose: #3177 Maybe we should adjust the response from WallabagRestController to take care of both configuration

I found that PR as well, but it doesn't explain why it was done 😊

What I can think of is to prevent spam account creation. But I would think a spam account can also be created via the frontend.

'allowed_registration' => $this->getParameter('fosuser_registration'),

I think that is a good workaround. I can create a PR for that.

@j0k3r j0k3r added this to the 2.6.0 milestone Mar 27, 2023
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

Successfully merging a pull request may close this issue.

2 participants