Metadata-Version: 2.1
Name: simple-xsrf
Version: 0.2.1
Summary: Simple package to protect against CSRF/XSRF attacks
Home-page: https://github.com/NWBY/simple-xsrf
License: MIT
Keywords: csrf,xsrf,security
Author: Sam Newby
Author-email: sam.newby19@gmail.com
Requires-Python: >=3.8,<4.0
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Requires-Dist: cryptography (>=38.0.0,<38.1.0)
Project-URL: Repository, https://github.com/NWBY/simple-xsrf
Description-Content-Type: text/markdown

# simple-xsrf

A simple package to create CSRF/XSRF tokens and protect against CSRF/XSRF attacks.

### Installation
```
pip install simple-xsrf
```

### Usage

To use this package you will need a fernet key also known as a secret key. To create a key:
```python
from cryptography.fernet import Fernet

key = Fernet.generate_key()
```
**Make sure to store this key in a secure place like a database so that you can access it later. You will need it to create your tokens and decrypt them**

Creating a token:
```python
from simple_xsrf.token import create_xsrf

token = create_xsrf(key)
```

Checking if a token is valid:
```python
from simple_xsrf.token import is_valid

is_token_valid = is_valid(key, token_from_request, token_from_storage)
```
You should store your token in a storage layer such as Redis or DynamoDB to be retrived later.

