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

AuthenticationMiddleware should also depend on authenticationModule being present #1611

Closed
3 of 4 tasks
jancastor opened this issue Apr 14, 2024 · 2 comments
Closed
3 of 4 tasks
Labels

Comments

@jancastor
Copy link

jancastor commented Apr 14, 2024

Sorting

  • I'm submitting a ...

    • bug report
    • feature request
    • support request
  • I confirm that I

    • used the search to make sure that a similar issue hasn't already been submit

Expected Behavior

I want to specify security tags on my controller methods but I don't want to do the authentication via the auto-generated Tsoa routes file.

Current Behavior

Not specifying the authenticationModule in the config throws an error when trying to hit the endpoint because of the missing expressAuthentication middleware.

I could provide a no-op function here but it has some undesired behavior, specifically re-setting the user field on the request object.

https://github.com/lukeautry/tsoa/blame/ac87a3b04ae2156fcd7b17eace4787bbd68c16be/packages/cli/src/routeGeneration/templates/express.hbs#L171

Possible Solution

This line:

useSecurity: this.metadata.controllers.some(controller => controller.methods.some(method => !!method.security.length)),

Should also check if authenticationModule is present

@jancastor
Copy link
Author

Happy to push up a PR for this

Copy link

This issue is stale because it has been open 30 days with no activity. Remove stale label or comment or this will be closed in 5 days

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant