-
Notifications
You must be signed in to change notification settings - Fork 110
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
Wrong Security decorator signature #91
Comments
I can also confirm the Auth header is broken. |
This is really annoying, could you please merge the suggestion in |
@evelyne24, Two fixes have been given here : thiagobustamante/typescript-rest-swagger#76 (comment) |
This problem requires changes in both typescript-rest and typescript-rest-swagger projects... I finished the changes in typescript-rest and I am working to finish the changes in typescript-rest-swagger. Typescript-rest-swagger will receive a major version soon. It is an old project that needs a refactory... And I was postponing it. But the idea is: Add an optional parameter to Server.registerAuthenticator(new PassportAuthenticator(strategy), 'MyAuth'); The presious contract is still valid, and if not provided, it will register an authenticator with name It will solve the problem with swagger generation, and also allow us to define multiple authentication schemas in typescript-rest. We can now reference which authenticator we want to use in our classes or methods with the @Path('myPath')
export class MultipleAuthenticateRole {
@Context
public context: ServiceContext;
@GET
@Path('myPath1')
@Security('ROLE_ADMIN', 'MyAuth')
public test() {
return this.context.request.user;
}
@GET
@Path('myPath2')
@Security('ROLE_ADMIN')
public test2() {
return this.context.request.user;
}
} In the previous example, the two endpoints will use different authenticators. The second one will use the It is already implemented (here) and will be available this week (I need to update the documentation before publish it to npm). But I still need to change typescript-rest-swagger. The change is to remove the decorator Security from that project and consider only the decorator defined here, in typescript-rest |
Done. Available in 2.2.0 |
Thank you. Great work, will test it tomorrow. Best regards. |
I have an issue when I try to implement it as in your example:
|
Related to thiagobustamante/typescript-rest-swagger#76 (comment)
Security decorator needs two params to be generated correctfully.
eg :
@Security("bearer", ["admin","operator"])
In typescript-rest, you only implemented the second parameters (roles), so Swagger can't recognize it and generate swagger.yaml file properly :
security: - '[object Object]': []
instead of
security: - 'bearer': ["admin", "operator"]
The text was updated successfully, but these errors were encountered: