# 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.
Raw data
{
"_id": null,
"home_page": "https://github.com/NWBY/simple-xsrf",
"name": "simple-xsrf",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.8,<4.0",
"maintainer_email": "",
"keywords": "csrf,xsrf,security",
"author": "Sam Newby",
"author_email": "sam.newby19@gmail.com",
"download_url": "https://files.pythonhosted.org/packages/65/14/414ffbc377e61acb8ef5fb8104b4bed2c2bcae7ec1a58fe42a64ec1d7e9f/simple_xsrf-0.2.1.tar.gz",
"platform": null,
"description": "# simple-xsrf\n\nA simple package to create CSRF/XSRF tokens and protect against CSRF/XSRF attacks.\n\n### Installation\n```\npip install simple-xsrf\n```\n\n### Usage\n\nTo use this package you will need a fernet key also known as a secret key. To create a key:\n```python\nfrom cryptography.fernet import Fernet\n\nkey = Fernet.generate_key()\n```\n**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**\n\nCreating a token:\n```python\nfrom simple_xsrf.token import create_xsrf\n\ntoken = create_xsrf(key)\n```\n\nChecking if a token is valid:\n```python\nfrom simple_xsrf.token import is_valid\n\nis_token_valid = is_valid(key, token_from_request, token_from_storage)\n```\nYou should store your token in a storage layer such as Redis or DynamoDB to be retrived later.\n",
"bugtrack_url": null,
"license": "MIT",
"summary": "Simple package to protect against CSRF/XSRF attacks",
"version": "0.2.1",
"split_keywords": [
"csrf",
"xsrf",
"security"
],
"urls": [
{
"comment_text": "",
"digests": {
"md5": "2b010a6b8f745309638c10c2360dd981",
"sha256": "a2565dacb5b7b2e42d2b7429c545cadc0a9df775fec0fed6ce1d24a312efb5d8"
},
"downloads": -1,
"filename": "simple_xsrf-0.2.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "2b010a6b8f745309638c10c2360dd981",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8,<4.0",
"size": 2300,
"upload_time": "2022-12-05T22:28:32",
"upload_time_iso_8601": "2022-12-05T22:28:32.278952Z",
"url": "https://files.pythonhosted.org/packages/14/af/3a064b00d27abd2977b991d061822582e2c26bb98db731fcbc70750ae5f1/simple_xsrf-0.2.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"md5": "a7bf95c2e10052139e315070b0effe03",
"sha256": "f45b281d8afa451241e89d5e98e03972b00687b273d8ca4a2921ea5d1a19f191"
},
"downloads": -1,
"filename": "simple_xsrf-0.2.1.tar.gz",
"has_sig": false,
"md5_digest": "a7bf95c2e10052139e315070b0effe03",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8,<4.0",
"size": 2077,
"upload_time": "2022-12-05T22:28:34",
"upload_time_iso_8601": "2022-12-05T22:28:34.005210Z",
"url": "https://files.pythonhosted.org/packages/65/14/414ffbc377e61acb8ef5fb8104b4bed2c2bcae7ec1a58fe42a64ec1d7e9f/simple_xsrf-0.2.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2022-12-05 22:28:34",
"github": true,
"gitlab": false,
"bitbucket": false,
"github_user": "NWBY",
"github_project": "simple-xsrf",
"lcname": "simple-xsrf"
}