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

Empty auth leads to traceback #72

Open
jbergstroem opened this issue Apr 8, 2019 · 1 comment
Open

Empty auth leads to traceback #72

jbergstroem opened this issue Apr 8, 2019 · 1 comment

Comments

@jbergstroem
Copy link

In gitlab CI we currently use _auth to pass credentials (username/auth token as base64). While some of the CI users were testing this they forgot to pass credentials which ultimately led to a http 500. This led to some confusion since the expected reply should likely be 400 not authenticated. Steps to reproduce:

$ export NPM_USERNAME="" && export NPM_TOKEN=""
$ npm config set @foo:registry=https://mysite.com/npm
$ export AUTH=$(echo "$NPM_USERNAME:$NPM_TOKEN" | base64)
$ npm config set //mysite.com/npm/:_auth=$AUTH
$ npm install --no-audit
info <-- 10.0.1.5 requested 'GET /@foo/bar/-/bar-1.0.0.tgz'
 error--- unexpected error: `token` (private-token) or `oauth_token` is mandatory
Error: `token` (private-token) or `oauth_token` is mandatory
    at new BaseModel (/opt/verdaccio-gitlab/node_modules/gitlab/dist/latest/infrastructure/BaseService.js:33:13)
    at new Groups (/opt/verdaccio-gitlab/node_modules/gitlab/dist/latest/services/Groups.js:10:1)
    at Bundle.Object.entries.forEach (/opt/verdaccio-gitlab/node_modules/gitlab/dist/latest/infrastructure/Bundler.js:13:22)
    at Array.forEach (<anonymous>)
    at new Bundle (/opt/verdaccio-gitlab/node_modules/gitlab/dist/latest/infrastructure/Bundler.js:12:32)
    at VerdaccioGitLab.authenticate (/opt/verdaccio-gitlab/build/gitlab.js:82:23)
    at next (/opt/verdaccio/build/lib/auth.js:94:14)
    at Auth.authenticate (/opt/verdaccio/build/lib/auth.js:122:7)
    at Auth._handleAESMiddleware (/opt/verdaccio/build/lib/auth.js:299:12)
    at /opt/verdaccio/build/lib/auth.js:258:14
    at Layer.handle [as handle_request] (/opt/verdaccio/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/verdaccio/node_modules/express/lib/router/index.js:317:13)
    at /opt/verdaccio/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/verdaccio/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/verdaccio/node_modules/express/lib/router/index.js:275:10)
    at Function.handle (/opt/verdaccio/node_modules/express/lib/router/index.js:174:3)
    at router (/opt/verdaccio/node_modules/express/lib/router/index.js:47:12)
    at Layer.handle [as handle_request] (/opt/verdaccio/node_modules/express/lib/router/layer.js:95:5)
    at trim_prefix (/opt/verdaccio/node_modules/express/lib/router/index.js:317:13)
    at /opt/verdaccio/node_modules/express/lib/router/index.js:284:7
    at Function.process_params (/opt/verdaccio/node_modules/express/lib/router/index.js:335:12)
    at next (/opt/verdaccio/node_modules/express/lib/router/index.js:275:10)
@dlouzan
Copy link
Collaborator

dlouzan commented Apr 8, 2019

I'll take a deeper look tomorrow, but I guess we just need to do some defensive programming and properly check parameters :-)

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

No branches or pull requests

2 participants