lukeautry / tsoa

Build OpenAPI-compliant REST APIs using TypeScript and Node
MIT License
3.32k stars 481 forks source link

AuthenticationMiddleware should also depend on authenticationModule being present #1611

Closed jancastor closed 1 month ago

jancastor commented 2 months ago

Sorting

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: https://github.com/lukeautry/tsoa/blob/ac87a3b04ae2156fcd7b17eace4787bbd68c16be/packages/cli/src/routeGeneration/routeGenerator.ts#L146

Should also check if authenticationModule is present

jancastor commented 2 months ago

Happy to push up a PR for this

github-actions[bot] commented 1 month ago

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