Skip to content

Conversation

Simran-B
Copy link
Contributor

@Simran-B Simran-B commented Jan 30, 2020

Description

Don't cast non-string passwords to string (e.g. undefined to "undefined").

I'm not sure if value.password instanceof String is needed or if a test for plain strings would be sufficient. Or should it explicitly test for undefined? Because people expect whatever they pass to be converted to string implicitly, except the blank password case?

Should the username also be checked?

Motivation and Context

Empty passwords for basic HTTP authorization is a valid use case (see swagger-api/swagger-ui#5410) and I opened a PR to allow this in the frontend (swagger-api/swagger-ui#5812), but it turned out that the swagger-client casts the undefined password to a string, leading to an incorrect base64-encoded password.

  • "root:undefined""cm9vdDp1bmRlZmluZWQ="
  • "root:""cm9vdDo="

How Has This Been Tested?

webpack --config webpack\test_webpack_build.babel.js
jest --runInBand -t "swagger2 - execute - applySecurities"
jest --runInBand -t "Authorization - OpenAPI Specification 3.0"

Types of changes

  • No code changes (changes to documentation, CI, metadata, etc)
  • Dependency changes (any modification to dependencies in package.json)
  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

@Simran-B Simran-B marked this pull request as ready for review January 30, 2020 01:14
Copy link
Contributor

@shockey shockey left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left a couple of suggestions — please respond to them and we'll go from there @Simran-B!

@Simran-B
Copy link
Contributor Author

Simran-B commented Mar 9, 2020

@shockey Should be good to go. Unsure about the Swagger-UI PR however swagger-api/swagger-ui#5812

@shockey shockey merged commit df8495a into swagger-api:master Mar 22, 2020
@Simran-B Simran-B deleted the patch-1 branch March 23, 2020 08:15
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.

2 participants