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(router, admin): Admin Swagger headers and route paths #83

Merged
merged 5 commits into from
Mar 21, 2022
Merged

Conversation

kon14
Copy link
Contributor

@kon14 kon14 commented Mar 20, 2022

Closes #80 and generally improves Swagger route doc generation.

  • Admin routes are now properly prefixed by /admin/ so that Swagger users no longer need to guess the proper baseUrl.
  • Admin routes now require proper admin headers.

This PR also converts Admin router's Authentication header format from JWT adminToken to Bearer adminToken.
This change improves compatibility with OpenAPI and Swagger, while also improving consistency with user authentication.

This bit is not a breaking change as backwards compatibility has been preserved.

What kind of change does this PR introduce? (check at least one)

  • Bugfix
  • Feature
  • Code style update
  • Refactor
  • Build-related changes
  • Other, please describe:

Does this PR introduce a breaking change? (check one)

  • Yes
  • No

The PR fulfills these requirements:

  • It's submitted to the main branch
  • When resolving a specific issue, it's referenced in the PR's title (e.g. fix #xxx, where "xxx" is the issue number)

Admin's AuthMiddleware 'Authentication' header now prefixes its admin
token with 'Bearer ' (previously 'JWT ').

This change improves compatibility with OpenAPI and Swagger,
while also improving consistency with user authentication.

This is not a breaking change as backwards compatibility has been
preserved.
@kon14
Copy link
Contributor Author

kon14 commented Mar 20, 2022

any types due to pre-existing routeDoc missing a type. Could technically add a type for that one tho.

clientSecret: [],
},
],
security: JSON.parse(JSON.stringify(this._routerMetadata.globalSecurityHeaders)),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

We could also entirely avoid repeated stringifications by just passing a pre-stringified globalSecurityHeaders instead. Totally type hacky, but definitely worth it perf-wise.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ended up stringifying once per Swagger construction instead (that makes 2 times total).

@kkopanidis kkopanidis merged commit 594bfec into main Mar 21, 2022
@kkopanidis kkopanidis deleted the swagger branch March 21, 2022 10:22
kkopanidis pushed a commit that referenced this pull request Mar 24, 2022
* fix(router,admin): Admin Swagger using User headers
* fix(router,admin): Admin Swagger routes not prefixed by '/admin'
* chore(admin): Bearer prefix for admin Authentication header
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.

[BUG] Admin Swagger uses User Security Headers
2 participants