Closed kwhitaker closed 3 years ago
Maybe some of the answers / discussions in https://github.com/lukeautry/tsoa/issues/855 could help ?
Rather new to TSOA myself so I may have missed an obvious point. We have our domain and persistence already written, one being checkAuthTokenUsecase(token: string, secret: string, userStore: UserStore)
(JWT) and its counterpart generateAuthToken(user: User, secret: string, userStore: UserStore)
.
I would need, in my authentication module function (export function expressAuthentication( request: express.Request, securityName: string, scopes?: string[] ): Promise<any>
) to inject the UserStore instance – so I can pass it on to our use case function.
I do not see where to pass additional parameters to the authentication module function.
@lazharichir do the comments in here help : https://github.com/lukeautry/tsoa/issues/855#issuecomment-735431085 ?
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
Our API has to talk to another REST API. In order to keep things streamlined, I've written an API Client singleton that each of the TSOA classes have access to. I'm using Tsyringe for IOC to accomplish this, by decorating the API Client with
@singleton
and decorating the controller classes with@injectable
.I have a authentication module in place for making sure each request coming into the TSOA API has a JWT, and in order to provide that JWT to each of my controller methods I'm using the
@Request()
type from TSOA to grab the header, and then forward them into the API Client. This is obviously not very DRY. What I'd like to do is have the authentication module send the JWT to the API Client when its validated. I was wondering if this was possible.I recognize that this might be a better question for the TSyringe folks, but all of their documentation revolves around class decorators, and I was wondering if you all had a way I could just wrap or otherwise provide the API client to the authentication module function. Thanks.
Sorting
I'm submitting a ...
I confirm that I
Context (Environment)
Version of the library: 3.6.1 Version of NodeJS: 14.15.4
Authentication Module
API Client