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

Fix basic auth with empty username or password #3325

Merged
merged 1 commit into from Jan 10, 2022

Conversation

hardillb
Copy link
Member

@hardillb hardillb commented Jan 5, 2022

fixes #3324

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)

Proposed changes

Add check for undefined values and replace with empty string

Checklist

  • I have read the contribution guidelines
  • For non-bugfix PRs, I have discussed this change on the forum/slack team.
  • I have run grunt to verify the unit tests pass
  • I have added suitable unit tests to cover the new/changed functionality

@coveralls
Copy link

Coverage Status

Coverage increased (+0.004%) to 67.365% when pulling 44616c6 on hardillb:http-basic-username-only into aaa2b4c on node-red:master.

@dceejay
Copy link
Member

dceejay commented Jan 6, 2022

looks sensible to me.

@tobiasoort
Copy link
Contributor

tobiasoort commented Jan 8, 2022

undefined is falsey in JS, so if both are undefined this if would be skipped. Afaik it's valid to only have b64(":") as a basic auth cred (Og==). I think that's still not possible to achieve with this fix in place.

@hardillb
Copy link
Member Author

hardillb commented Jan 8, 2022

Nah, that's and edge case too far and basically pointless. Anybody depending on that behaviour deserves to have it fail.

@tobiasoort
Copy link
Contributor

First to be very clear: I very much agree with you. People playing with basic-auth with no actual credentials are screwed anyway - we don't have to support them :) This is more of an interesting discussion for me. If you feel at any moment irritated or tired by me, let me know. I would not let this point stop this PR from getting merged.

I just wonder what that if is trying to prevent - you either enter a username or a password or both? Why? Also, Is that clear from the UX that that's the only valid input?

I prefer no code over 'what is that actually doing here' code.

@hardillb
Copy link
Member Author

hardillb commented Jan 9, 2022

We need the if because we can't be 100% sure what else is in the credentials object, all we know is that it has 1 or more properties. Also it may hold other authentication methods, either now or in the future.

@knolleary knolleary merged commit 062f762 into node-red:master Jan 10, 2022
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 this pull request may close these issues.

HTTP-request node fails to authenticate when username or password is empty
5 participants