From 23aa0a7d447e1f603e2e585a140cfb5f37a92fd1 Mon Sep 17 00:00:00 2001 From: CoprDistGit Date: Fri, 5 May 2023 04:49:42 +0000 Subject: automatic import of python-drf-recaptcha --- python-drf-recaptcha.spec | 459 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 459 insertions(+) create mode 100644 python-drf-recaptcha.spec (limited to 'python-drf-recaptcha.spec') diff --git a/python-drf-recaptcha.spec b/python-drf-recaptcha.spec new file mode 100644 index 0000000..c3e857b --- /dev/null +++ b/python-drf-recaptcha.spec @@ -0,0 +1,459 @@ +%global _empty_manifest_terminate_build 0 +Name: python-drf-recaptcha +Version: 2.2.3 +Release: 1 +Summary: Django rest framework recaptcha field serializer. +License: MIT +URL: https://github.com/llybin/drf-recaptcha +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/95/9b/b603c9ca547d185911131e528a946701a89554a355b67ff6fea9715b2f2c/drf-recaptcha-2.2.3.tar.gz +BuildArch: noarch + +Requires: python3-django +Requires: python3-djangorestframework +Requires: python3-django-ipware + +%description +# Django REST reCAPTCHA + +**Django REST reCAPTCHA v2 and v3 field serializer** + +[![CI](https://github.com/llybin/drf-recaptcha/workflows/tests/badge.svg)](https://github.com/llybin/drf-recaptcha/actions) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a9b44d24cba74c75bca6472b2ee8da67)](https://www.codacy.com/app/llybin/drf-recaptcha?utm_source=github.com&utm_medium=referral&utm_content=llybin/drf-recaptcha&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/a9b44d24cba74c75bca6472b2ee8da67)](https://www.codacy.com/app/llybin/drf-recaptcha?utm_source=github.com&utm_medium=referral&utm_content=llybin/drf-recaptcha&utm_campaign=Badge_Coverage) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![PyPI](https://img.shields.io/pypi/v/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) +[![PyPI - Downloads](https://img.shields.io/pypi/dm/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) +[![PyPI - License](https://img.shields.io/pypi/l/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) + +## Requirements + +* Python: 3.7, 3.8, 3.9, 3.10, 3.11 +* Django: 3.2, 4.0, 4.1, 4.2 +* DRF: 3.11, 3.12, 3.13, 3.14 + +## Installation + +1. [Sign up for reCAPTCHA](https://www.google.com/recaptcha/) +2. Install with `pip install drf-recaptcha` +3. Add `"drf_recaptcha"` to your `INSTALLED_APPS` settings. +4. Set in settings `DRF_RECAPTCHA_SECRET_KEY` + +```python +INSTALLED_APPS = [ + ..., + "drf_recaptcha", + ..., +] + +... + +DRF_RECAPTCHA_SECRET_KEY = "YOUR SECRET KEY" +``` + +## Usage + +```python +from rest_framework.serializers import Serializer, ModelSerializer +from drf_recaptcha.fields import ReCaptchaV2Field, ReCaptchaV3Field +from feedback.models import Feedback + + +class V2Serializer(Serializer): + recaptcha = ReCaptchaV2Field() + ... + +class GetOTPView(APIView): + def post(self, request): + serializer = V2Serializer(data=request.data, context={"request": request}) + serializer.is_valid(raise_exception=True) + ... + +class V3Serializer(Serializer): + recaptcha = ReCaptchaV3Field(action="example") + ... + +class V3WithScoreSerializer(Serializer): + recaptcha = ReCaptchaV3Field( + action="example", + required_score=0.6, + ) + ... + +class GetReCaptchaScore(APIView): + def post(self, request): + serializer = V3WithScoreSerializer(data=request.data, context={"request": request}) + serializer.is_valid() + score = serializer.fields['recaptcha'].score + ... + +class FeedbackSerializer(ModelSerializer): + recaptcha = ReCaptchaV2Field() + + class Meta: + model = Feedback + fields = ("phone", "full_name", "email", "comment", "recaptcha") + + def validate(self, attrs): + attrs.pop("recaptcha") + ... + return attrs +``` + +## Settings + +`DRF_RECAPTCHA_SECRET_KEY` - set your Google reCAPTCHA secret key. Type: str. + +`DRF_RECAPTCHA_DEFAULT_V3_SCORE` - by default: `0.5`. Type: float. + +`DRF_RECAPTCHA_ACTION_V3_SCORES` - by default: `{}`. Type: dict. You can define specific score for each action e.g. `{"login": 0.6, "feedback": 0.3}` + +`DRF_RECAPTCHA_DOMAIN` - by default: `www.google.com`. Type: str. + +`DRF_RECAPTCHA_PROXY` - by default: `{}`. Type: dict. e.g. `{'http': 'http://127.0.0.1:8000', 'https': 'https://127.0.0.1:8000'}` + +`DRF_RECAPTCHA_VERIFY_REQUEST_TIMEOUT` - by default: `10`. Type: int. + +## reCAPTCHA v3 + +Validation is passed if the score value returned by Google is greater than or equal to required score. + +Required score value: `0.0 - 1.0` + +### Priority of score value + +If not defined or zero in current item then value from next item. + +1. Value for action in settings `DRF_RECAPTCHA_ACTION_V3_SCORES` +2. Value in argument `required_score` of field +3. Default value in settings `DRF_RECAPTCHA_DEFAULT_V3_SCORE` +4. Default value `0.5` + +## Testing + +Set `DRF_RECAPTCHA_TESTING=True` in settings, no request to Google, no warnings, `DRF_RECAPTCHA_SECRET_KEY` is not required, set returning verification result in setting below. + +`DRF_RECAPTCHA_TESTING_PASS=True|False` - all responses are pass, default `True`. + +Use `from django.test import override_settings` + +## Credits + +[django-recaptcha](https://github.com/praekelt/django-recaptcha) + +reCAPTCHA copyright 2012 Google. + + +%package -n python3-drf-recaptcha +Summary: Django rest framework recaptcha field serializer. +Provides: python-drf-recaptcha +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-drf-recaptcha +# Django REST reCAPTCHA + +**Django REST reCAPTCHA v2 and v3 field serializer** + +[![CI](https://github.com/llybin/drf-recaptcha/workflows/tests/badge.svg)](https://github.com/llybin/drf-recaptcha/actions) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a9b44d24cba74c75bca6472b2ee8da67)](https://www.codacy.com/app/llybin/drf-recaptcha?utm_source=github.com&utm_medium=referral&utm_content=llybin/drf-recaptcha&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/a9b44d24cba74c75bca6472b2ee8da67)](https://www.codacy.com/app/llybin/drf-recaptcha?utm_source=github.com&utm_medium=referral&utm_content=llybin/drf-recaptcha&utm_campaign=Badge_Coverage) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![PyPI](https://img.shields.io/pypi/v/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) +[![PyPI - Downloads](https://img.shields.io/pypi/dm/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) +[![PyPI - License](https://img.shields.io/pypi/l/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) + +## Requirements + +* Python: 3.7, 3.8, 3.9, 3.10, 3.11 +* Django: 3.2, 4.0, 4.1, 4.2 +* DRF: 3.11, 3.12, 3.13, 3.14 + +## Installation + +1. [Sign up for reCAPTCHA](https://www.google.com/recaptcha/) +2. Install with `pip install drf-recaptcha` +3. Add `"drf_recaptcha"` to your `INSTALLED_APPS` settings. +4. Set in settings `DRF_RECAPTCHA_SECRET_KEY` + +```python +INSTALLED_APPS = [ + ..., + "drf_recaptcha", + ..., +] + +... + +DRF_RECAPTCHA_SECRET_KEY = "YOUR SECRET KEY" +``` + +## Usage + +```python +from rest_framework.serializers import Serializer, ModelSerializer +from drf_recaptcha.fields import ReCaptchaV2Field, ReCaptchaV3Field +from feedback.models import Feedback + + +class V2Serializer(Serializer): + recaptcha = ReCaptchaV2Field() + ... + +class GetOTPView(APIView): + def post(self, request): + serializer = V2Serializer(data=request.data, context={"request": request}) + serializer.is_valid(raise_exception=True) + ... + +class V3Serializer(Serializer): + recaptcha = ReCaptchaV3Field(action="example") + ... + +class V3WithScoreSerializer(Serializer): + recaptcha = ReCaptchaV3Field( + action="example", + required_score=0.6, + ) + ... + +class GetReCaptchaScore(APIView): + def post(self, request): + serializer = V3WithScoreSerializer(data=request.data, context={"request": request}) + serializer.is_valid() + score = serializer.fields['recaptcha'].score + ... + +class FeedbackSerializer(ModelSerializer): + recaptcha = ReCaptchaV2Field() + + class Meta: + model = Feedback + fields = ("phone", "full_name", "email", "comment", "recaptcha") + + def validate(self, attrs): + attrs.pop("recaptcha") + ... + return attrs +``` + +## Settings + +`DRF_RECAPTCHA_SECRET_KEY` - set your Google reCAPTCHA secret key. Type: str. + +`DRF_RECAPTCHA_DEFAULT_V3_SCORE` - by default: `0.5`. Type: float. + +`DRF_RECAPTCHA_ACTION_V3_SCORES` - by default: `{}`. Type: dict. You can define specific score for each action e.g. `{"login": 0.6, "feedback": 0.3}` + +`DRF_RECAPTCHA_DOMAIN` - by default: `www.google.com`. Type: str. + +`DRF_RECAPTCHA_PROXY` - by default: `{}`. Type: dict. e.g. `{'http': 'http://127.0.0.1:8000', 'https': 'https://127.0.0.1:8000'}` + +`DRF_RECAPTCHA_VERIFY_REQUEST_TIMEOUT` - by default: `10`. Type: int. + +## reCAPTCHA v3 + +Validation is passed if the score value returned by Google is greater than or equal to required score. + +Required score value: `0.0 - 1.0` + +### Priority of score value + +If not defined or zero in current item then value from next item. + +1. Value for action in settings `DRF_RECAPTCHA_ACTION_V3_SCORES` +2. Value in argument `required_score` of field +3. Default value in settings `DRF_RECAPTCHA_DEFAULT_V3_SCORE` +4. Default value `0.5` + +## Testing + +Set `DRF_RECAPTCHA_TESTING=True` in settings, no request to Google, no warnings, `DRF_RECAPTCHA_SECRET_KEY` is not required, set returning verification result in setting below. + +`DRF_RECAPTCHA_TESTING_PASS=True|False` - all responses are pass, default `True`. + +Use `from django.test import override_settings` + +## Credits + +[django-recaptcha](https://github.com/praekelt/django-recaptcha) + +reCAPTCHA copyright 2012 Google. + + +%package help +Summary: Development documents and examples for drf-recaptcha +Provides: python3-drf-recaptcha-doc +%description help +# Django REST reCAPTCHA + +**Django REST reCAPTCHA v2 and v3 field serializer** + +[![CI](https://github.com/llybin/drf-recaptcha/workflows/tests/badge.svg)](https://github.com/llybin/drf-recaptcha/actions) +[![Codacy Badge](https://api.codacy.com/project/badge/Grade/a9b44d24cba74c75bca6472b2ee8da67)](https://www.codacy.com/app/llybin/drf-recaptcha?utm_source=github.com&utm_medium=referral&utm_content=llybin/drf-recaptcha&utm_campaign=Badge_Grade) +[![Codacy Badge](https://api.codacy.com/project/badge/Coverage/a9b44d24cba74c75bca6472b2ee8da67)](https://www.codacy.com/app/llybin/drf-recaptcha?utm_source=github.com&utm_medium=referral&utm_content=llybin/drf-recaptcha&utm_campaign=Badge_Coverage) +[![Code style: black](https://img.shields.io/badge/code%20style-black-000000.svg)](https://github.com/psf/black) +[![PyPI](https://img.shields.io/pypi/v/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) +[![PyPI - Downloads](https://img.shields.io/pypi/dm/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) +[![PyPI - License](https://img.shields.io/pypi/l/drf-recaptcha)](https://pypi.org/project/drf-recaptcha/) + +## Requirements + +* Python: 3.7, 3.8, 3.9, 3.10, 3.11 +* Django: 3.2, 4.0, 4.1, 4.2 +* DRF: 3.11, 3.12, 3.13, 3.14 + +## Installation + +1. [Sign up for reCAPTCHA](https://www.google.com/recaptcha/) +2. Install with `pip install drf-recaptcha` +3. Add `"drf_recaptcha"` to your `INSTALLED_APPS` settings. +4. Set in settings `DRF_RECAPTCHA_SECRET_KEY` + +```python +INSTALLED_APPS = [ + ..., + "drf_recaptcha", + ..., +] + +... + +DRF_RECAPTCHA_SECRET_KEY = "YOUR SECRET KEY" +``` + +## Usage + +```python +from rest_framework.serializers import Serializer, ModelSerializer +from drf_recaptcha.fields import ReCaptchaV2Field, ReCaptchaV3Field +from feedback.models import Feedback + + +class V2Serializer(Serializer): + recaptcha = ReCaptchaV2Field() + ... + +class GetOTPView(APIView): + def post(self, request): + serializer = V2Serializer(data=request.data, context={"request": request}) + serializer.is_valid(raise_exception=True) + ... + +class V3Serializer(Serializer): + recaptcha = ReCaptchaV3Field(action="example") + ... + +class V3WithScoreSerializer(Serializer): + recaptcha = ReCaptchaV3Field( + action="example", + required_score=0.6, + ) + ... + +class GetReCaptchaScore(APIView): + def post(self, request): + serializer = V3WithScoreSerializer(data=request.data, context={"request": request}) + serializer.is_valid() + score = serializer.fields['recaptcha'].score + ... + +class FeedbackSerializer(ModelSerializer): + recaptcha = ReCaptchaV2Field() + + class Meta: + model = Feedback + fields = ("phone", "full_name", "email", "comment", "recaptcha") + + def validate(self, attrs): + attrs.pop("recaptcha") + ... + return attrs +``` + +## Settings + +`DRF_RECAPTCHA_SECRET_KEY` - set your Google reCAPTCHA secret key. Type: str. + +`DRF_RECAPTCHA_DEFAULT_V3_SCORE` - by default: `0.5`. Type: float. + +`DRF_RECAPTCHA_ACTION_V3_SCORES` - by default: `{}`. Type: dict. You can define specific score for each action e.g. `{"login": 0.6, "feedback": 0.3}` + +`DRF_RECAPTCHA_DOMAIN` - by default: `www.google.com`. Type: str. + +`DRF_RECAPTCHA_PROXY` - by default: `{}`. Type: dict. e.g. `{'http': 'http://127.0.0.1:8000', 'https': 'https://127.0.0.1:8000'}` + +`DRF_RECAPTCHA_VERIFY_REQUEST_TIMEOUT` - by default: `10`. Type: int. + +## reCAPTCHA v3 + +Validation is passed if the score value returned by Google is greater than or equal to required score. + +Required score value: `0.0 - 1.0` + +### Priority of score value + +If not defined or zero in current item then value from next item. + +1. Value for action in settings `DRF_RECAPTCHA_ACTION_V3_SCORES` +2. Value in argument `required_score` of field +3. Default value in settings `DRF_RECAPTCHA_DEFAULT_V3_SCORE` +4. Default value `0.5` + +## Testing + +Set `DRF_RECAPTCHA_TESTING=True` in settings, no request to Google, no warnings, `DRF_RECAPTCHA_SECRET_KEY` is not required, set returning verification result in setting below. + +`DRF_RECAPTCHA_TESTING_PASS=True|False` - all responses are pass, default `True`. + +Use `from django.test import override_settings` + +## Credits + +[django-recaptcha](https://github.com/praekelt/django-recaptcha) + +reCAPTCHA copyright 2012 Google. + + +%prep +%autosetup -n drf-recaptcha-2.2.3 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-drf-recaptcha -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot - 2.2.3-1 +- Package Spec generated -- cgit v1.2.3