I've found that anonymous users ("npm adduser" has not yet been run) are allowed to download packages from Sinopia... which is what I would expect. However, I've also found that if a user has run "npm adduser", possibly because of using registry.npmjs.org instead of Sinopia, AND that user is not set up in the config file... the user is rejected from even downloading packages. I would expect rejection for publishing, but not downloading.
I see two possible solutions. If the basic_auth middleware were placed lower in index.js after all the routes that accept anonymous users but before any route that required auth... that might solve the problem. The other idea is to not fail a request immediately on bad auth, but let the route check when and if the user is needed. At that point the request could fail if anonymous users are not ok.
I am willing to work on either solution and submit a PR if you like, but want to get your opinion before putting any work into it.
I've found that anonymous users ("npm adduser" has not yet been run) are allowed to download packages from Sinopia... which is what I would expect. However, I've also found that if a user has run "npm adduser", possibly because of using registry.npmjs.org instead of Sinopia, AND that user is not set up in the config file... the user is rejected from even downloading packages. I would expect rejection for publishing, but not downloading.
I see two possible solutions. If the basic_auth middleware were placed lower in index.js after all the routes that accept anonymous users but before any route that required auth... that might solve the problem. The other idea is to not fail a request immediately on bad auth, but let the route check when and if the user is needed. At that point the request could fail if anonymous users are not ok.
I am willing to work on either solution and submit a PR if you like, but want to get your opinion before putting any work into it.