OpenAPITools / OpenAPITools/openapi-generator

[BUG] Typescript-node does not apply basic auth with blank username or password

Open
#5,446 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Client: TypeScript Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Description

Using Basic auth should be possible with empty username, however, 4.3.3 generates this code:

  let authenticationPromise = Promise.resolve();
        if (this.authentications.BasicAuth.username && this.authentications.BasicAuth.password) {
            authenticationPromise = authenticationPromise.then(() => this.authentications.BasicAuth.applyToRequest(localVarRequestOptions));
        }

since "" is falsy, auth is never applied if either username or password is empty.

openapi-generator version

Worked in 4.2.2, fails in 4.2.3. Introduced by #4896

OpenAPI declaration file content or url

N/A

Command line used for generation

openapi-generator generate -i api.yaml -g typescript-node --additional-properties=supportsES6=true

Related issues/PRs

introduced by #4896

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the issue with the supplied OpenAPI Generator command and compare typescript-node output between versions 4.2.2 and 4.2.3. Inspect the change introduced by #4896 and locate the generated BasicAuth handling; done means authentication is applied when either the username or password is blank, with a regression test covering that case.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
api, tooling
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.