# 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
2
3
4
5
6
7
8
- Session & cookies
- Passport.js
- TypeORM
- Mongoose
- GraphQL
- Socket.io
- Swagger
- AJV
- Multer
- Serve static files
- Templating
- Throw HTTP Exceptions
- Customize 404
- AWS
- Jest
- Seq
- Controllers
- Providers
- Model
- Converters
- Middlewares
- Pipes
- Interceptors
- Authentication
- Hooks
- Injection scopes
- Custom providers
- Custom endpoint decorator
- Testing