thiagobustamante / typescript-rest

This is a lightweight annotation-based expressjs extension for typescript.
MIT License
523 stars 110 forks source link

Multiple @Security tags? #146

Closed mr-short closed 3 years ago

mr-short commented 4 years ago

Using multiple security tags does not seem to work on a specific route or controller. It only uses the first one.

Is this supported?

mr-short commented 4 years ago

The answer is no, it is not supported. It looks like roles and authenticator are hard-coded properties on the decorated object, so additional @Security tags just overwrite it.

return new ServiceDecorator('Security')
    .withProperty('roles', roles)
    .withProperty('authenticator', name || 'default')
buildSecurityMiddlewares(serviceClass, serviceMethod) {
    let roles = _.compact(_.union(serviceMethod.roles, serviceClass.roles));
    const authenticatorName = serviceMethod.authenticator || serviceClass.authenticator;