# Decorator UseAuth

Decorator operation private
Module
import { UseAuth } from "@tsed/platform/platform-middlewares/src/decorators/useAuth"
Source/packages/platform/platform-middlewares/src/decorators/useAuth.ts

# Overview

function UseAuth(guardAuth: Type<any>, options?: IAuthOptions): Function;
Param Type Description
guardAuth Type 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

Other topics