# UseAuth Decorator operation

Module
import { UseAuth } from "@tsed/common"
Source/packages/common/src/mvc/decorators/method/useAuth.ts

# Overview

function UseAuth(guardAuth: Type<any>, options?: IAuthOptions): Function;
Param Type Description
guardAuth Type<any> A middleware which implement a custom auth strategy options

# Description

Use custom authentication strategy on your endpoint.

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

  @Get('/')
  @UseAuth(MyAuthStrategy, {role: 'admin'})
  public getResource(){}
}
1
2
3
4
5
6
7
8