Skip to content

UseAuth

@tsed/platform-middlewares

Usage

typescript
import { UseAuth } from "@tsed/platform-middlewares";

See /packages/platform/platform-middlewares/src/types/decorators/useAuth.ts.

Overview

ts
function UseAuth(guardAuth: Type<any>, options?: Record<string, unknown>): Function;
  • guardAuth (Type<any>): A middleware which implement a custom auth strategy

  • options (Record<string): Optional. Object passed to the customer auth strategy

Description

Use custom authentication strategy on your endpoint.

typescript
@Controller('/mypath')
@UseAuth(MyAuthStrategy)
class MyCtrl {

  @Get('/')
  @UseAuth(MyAuthStrategy, {role: 'admin'})
  public getResource(){}
}

Released under the MIT License.