jaredhanson / jaredhanson/passport-http

Password not required

Open
#30 1 comment 1 reaction 0 assignees View on GitHub
Dominant language
JavaScript
Stars
261
Forks
112
PR merge metrics
No merged PRs in 30d

Description

Some APIs (including mine!) use HTTP Basic Auth, but read the username as an API token and ignore the password field. Notably, [Stripe](https://stripe.com/docs/api/ruby#authentication) does this. It would be great to have the ability to pass a `passwordRequired` option, which defaults to true to preserve backwards compatability, but that can be set to false to disable the requirement.

From this:

```
var userid = credentials[0];
var password = credentials[1];
if (!userid || !password) {
return this.fail(this._challenge());
}
```

To this:

```
var userid = credentials[0];
var password = credentials[1];
if (!userid || (options.passwordRequired && !password)) {
return this.fail(this._challenge());
}
```

I'm happy to submit a pull request

Contributor guide

Open the contributing guide

Research direction

Start by locating the HTTP Basic authentication strategy code containing the credential validation shown in the issue, then inspect how strategy options are defined and passed. Add the passwordRequired option with its default behavior and verify that username-only credentials succeed when it is false while missing passwords still fail by default.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
authentication, backend
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.