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

Express basic auth is broken #395

Closed
matteofigus opened this issue Mar 8, 2017 · 4 comments
Closed

Express basic auth is broken #395

matteofigus opened this issue Mar 8, 2017 · 4 comments
Assignees

Comments

@matteofigus
Copy link
Member

This was introduced on #366 and is due to the fact express 4 needs a separate module to handle basic auth. Somehow, we didn't catch this in any test.

@federicomaffei is already working on it.

@debopamsengupta
Copy link
Member

debopamsengupta commented Mar 8, 2017

Hi, not sure if this is the same issue, but I came across this when looking to enable Basic Auth on a registry:

At https://github.com/opentable/oc/blob/master/src/cli/facade/publish.js#L127 , the parameters route and path are passed to putComponentToRegistry

putComponentToRegistry({ route: componentRoute, path: compressedPackagePath}, next);

and putComponentToRegistry is defined as

var putComponentToRegistry = function(options, cb){
      log.warn(format(strings.messages.cli.PUBLISHING, options.route));

      registry.putComponent(options, function(err, res){

        if(!!err){
       ...

and inside registry.putComponent at https://github.com/opentable/oc/blob/master/src/cli/domain/registry.js#L100

 putComponent: function(options, callback){
      if(!!options.username && !!options.password){
        requestsHeaders = _.extend(requestsHeaders, { 'Authorization': 'Basic ' + new Buffer(options.username + ':' + options.password).toString('base64') });
      }
...

we are checking for username and password, which will never be passed through.

Not sure then how the username and password can be used from the CLI oc publish ...

@matteofigus
Copy link
Member Author

@debopamsengupta I think that a separate issue. The cli actually tries to make an attempt without credentials, and in case of unauthorised, tries again by providing the credentials. In case of the CLI, it prompts the user asking for the values.

You can see that as soon as it has a failing attempt, it retries...
https://github.com/opentable/oc/blob/master/src/cli/facade/publish.js#L72-L82

@debopamsengupta
Copy link
Member

debopamsengupta commented Mar 8, 2017

@matteofigus would it be possible / would it make sense to enable username and password to be used on the first attempt ?
I ask because I'm trying to automate the publish step using our CI

it will auto-retry if the registry returns Unauthorized

@matteofigus
Copy link
Member Author

@debopamsengupta you know that you can pass username and password on the cli like oc publish component --username=hello --password=... 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants