Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/auralshin/csrf-nest
https://github.com/auralshin/csrf-nest
Last synced: 6 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/auralshin/csrf-nest
- Owner: auralshin
- Created: 2024-02-13T05:57:11.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-02-13T05:58:55.000Z (11 months ago)
- Last Synced: 2024-05-02T05:11:21.358Z (8 months ago)
- Language: TypeScript
- Size: 95.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# NestJS CSRF Protection Package
This package provides a robust CSRF (Cross-Site Request Forgery) protection mechanism for NestJS applications, leveraging dynamic module registration for flexible configuration.
## Features
- Easy integration with NestJS projects.
- Customizable token generation and validation routes.
- Secure token handling using cookies.## Installation
```bash
npm install csrf-nest
```## Usage
1. **Module Import**: Import `CsrfModule` into your application module:
```typescript
import { CsrfModule } from 'csrf-nest';@Module({
imports: [
CsrfModule.forRoot({
tokenGenerationUrl: '/api/csrf-token', // optional custom path
}),
],
})
export class AppModule {}
```2. **Service Injection** (optional): If you need direct access to CSRF functionality:
```typescript
import { CsrfService } from 'csrf-nest';@Injectable()
export class YourService {
constructor(private readonly csrfService: CsrfService) {}
}
```## Configuration
TBH## Contributing
TBH
## License