Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/ricardoferreirasilva/nestjs-referers
Decorator based validation for request referers in NestJS.
https://github.com/ricardoferreirasilva/nestjs-referers
decorator http nestjs nestjs-referers referers request
Last synced: 27 days ago
JSON representation
Decorator based validation for request referers in NestJS.
- Host: GitHub
- URL: https://github.com/ricardoferreirasilva/nestjs-referers
- Owner: ricardoferreirasilva
- License: mit
- Created: 2020-01-08T15:16:15.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-24T01:11:29.000Z (almost 2 years ago)
- Last Synced: 2024-11-15T04:07:25.142Z (about 2 months ago)
- Topics: decorator, http, nestjs, nestjs-referers, referers, request
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/nestjs-referers
- Size: 1.19 MB
- Stars: 3
- Watchers: 2
- Forks: 1
- Open Issues: 13
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
Awesome Lists containing this project
README
NestJS Referers
Decorator based validation for request referers.
### Introduction
NestJS Referers is a simple package that implements decorator based validation for the referer header of incoming HTTP requests.
The adopted syntax for specifying allowed URL's was based on [Algolia's](https://www.algolia.com/doc/guides/security/api-keys/in-depth/api-key-restrictions/) example.A few examples:
- https://algolia.com/* will restrict access to all referers starting with https://algolia.com
- *.algolia.com will restrict access to all referers ending with .algolia.com
- If you want to allow access for the full domain algolia.com, you can use *algolia.com/*Regarding security, you should know that referers can be easily spoofed like any other HTTP header, so you should not rely on this technique alone for securing requests.
### Installation
```bash
npm i nestjs-referers --save
```### Basic usage
You can checkout the usage of this package with this example.
**test.controller.ts**
```typescript
import { Controller,Get} from '@nestjs/common';
import { ValidateReferers } from "nestjs-referers"@Controller('test')
export class TestController {
constructor(){}@Get('/')
@ValidateReferers("*localhost*","https://website/*")
async testRoute() {
return "OK"
}
}```
### Installation for Development
1. Clone the repo
2. Run npm/yarn install```bash
cd nestjs-referers
npm install
```## Change Log
See [Changelog](CHANGELOG.md) for more information.
## Contributing
All contributions are welcome! Check out [Contributing](CONTRIBUTING.md).
## Author
**Ricardo Ferreira da Silva (Check out my [Website](https://ricardoferreirasilva.pt))**
## License
Licensed under the MIT License - see the [LICENSE](LICENSE) file for details.