summaryrefslogtreecommitdiff
path: root/python-pyjwt-utils.spec
diff options
context:
space:
mode:
Diffstat (limited to 'python-pyjwt-utils.spec')
-rw-r--r--python-pyjwt-utils.spec366
1 files changed, 366 insertions, 0 deletions
diff --git a/python-pyjwt-utils.spec b/python-pyjwt-utils.spec
new file mode 100644
index 0000000..69f1fc1
--- /dev/null
+++ b/python-pyjwt-utils.spec
@@ -0,0 +1,366 @@
+%global _empty_manifest_terminate_build 0
+Name: python-pyjwt-utils
+Version: 1.0.4
+Release: 1
+Summary: PyJwt-Utils is a wrapper to facility your token encode/decode
+License: MIT
+URL: https://github.com/shinneider/pyjwt-utils
+Source0: https://mirrors.aliyun.com/pypi/web/packages/a3/9a/e10f0b830c34a26802857ce3d21b81da94e10e6cee158294f75c7980403c/pyjwt-utils-1.0.4.tar.gz
+BuildArch: noarch
+
+
+%description
+PyJwt Utils
+=
+PyJwt-Utils is a wrapper to facility your token encode/decode.
+
+If you use or like the project, click `Star` and `Watch` to generate metrics and i evaluate project continuity.
+
+# Install:
+ pip install pyjwt-utils
+
+# Usage:
+1. In your file:
+ ```
+ from jwt_utils.django import JwtEncode, JwtDecode
+ ...
+
+ token = JwtEncode(
+ signing_key='...', # Default None
+ algorithm='HS256', # Default -> 'HS256', accepts ['HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512']
+ iss=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1)
+ sub=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2)
+ aud=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3)
+ exp=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4)
+ nbf=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5)
+ iat=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.6)
+ auto_iat=False, # Default False (generate iat with current time) - (used only if IAT is None)
+ jti=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.7)
+ auto_jti=False, # Default False (generate jti with random hex) - (used only if JTI is None)
+ from_time=None # Default datetime.utcnow() - Base time from iss and nbf
+ payload={} # Your data
+ ).encode()
+
+ payload = JwtDecode(
+ token='...'
+ verify_iss=False, # Default False (verify jwt iss)
+ verify_aud=False, # Default False (verify jwt aud)
+ verify_exp=False, # Default False (verify jwt exp)
+ verify_nbf=False, # Default False (verify jwt nbf)
+ verify_iat=False, # Default False (verify jwt iat)
+ leeway=0 # Default 0 (validate time leeway)
+ ).decode(
+ raise_except=False # Default False (check `jwt.exceptions` for available exceptions)
+ )
+ ```
+
+# Usage (Django):
+
+OBS: This require `Django` and `Django Rest Framework` to work.
+
+1. Add to your `INSTALLED_APPS`, in `settings.py`:
+ ```
+ INSTALLED_APPS = [
+ ...
+ 'jwt_utils.django',
+ ...
+ ]
+ ```
+
+1. Add this configuration on `settings.py`:
+ ```
+ from datetime import timedelta
+ ...
+
+ JWT_UTILS = {
+ # all settings with None or False are ignored by default.
+
+ # Generating Jwt
+ 'SIGNING_KEY': settings.SECRET_KEY, # Default -> settings.SECRET_KEY
+ 'ALGORITHM': 'HS256', # Default -> 'HS256', accepts ['HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512']
+ 'ISSUER': 'myapp', # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1)
+ 'SUBJECT': None, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2)
+ 'AUDIENCE': ['web', 'mobile'], # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3)
+ 'EXPIRATION': timedelta(minutes=20), # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4)
+ 'NOT_BEFORE': timedelta(seconds=0), # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5)
+ 'IAT': None, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.6)
+ 'AUTO_IAT': True, Auto generate IAT claim (used only if IAT is None)
+ 'JTI': True, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.7)
+ 'AUTO_JTI': True, Auto generate JTI claim (used only if JTI is None)
+
+ # Checking Jwt
+ 'VERIFY_ISSUER': True, # Default `ISSUER is not None`
+ 'VERIFY_AUDIENCE': True, # Default `AUDIENCE is not None`
+ 'VERIFY_EXPIRATION': True, # Default `EXPIRATION is not None`
+ 'VERIFY_NOT_BEFORE': True, # Default `NOT_BEFORE is not None`
+ 'VERIFY_IAT': True, # Default `IAT is not None or AUTO_IAT`
+ 'VERIFY_MAX_LEEWAY': 0, # Default 0, validate time leeway
+ }
+ ```
+
+1. In your file:
+ ```
+ from jwt_utils.django import JwtEncode, JwtDecode
+ ...
+
+ token = JwtEncode(payload={}).encode()
+
+ payload = JwtDecode(token).decode(
+ raise_except=False # Default False (check `jwt.exceptions` for available exceptions)
+ )
+ ```
+
+%package -n python3-pyjwt-utils
+Summary: PyJwt-Utils is a wrapper to facility your token encode/decode
+Provides: python-pyjwt-utils
+BuildRequires: python3-devel
+BuildRequires: python3-setuptools
+BuildRequires: python3-pip
+%description -n python3-pyjwt-utils
+PyJwt Utils
+=
+PyJwt-Utils is a wrapper to facility your token encode/decode.
+
+If you use or like the project, click `Star` and `Watch` to generate metrics and i evaluate project continuity.
+
+# Install:
+ pip install pyjwt-utils
+
+# Usage:
+1. In your file:
+ ```
+ from jwt_utils.django import JwtEncode, JwtDecode
+ ...
+
+ token = JwtEncode(
+ signing_key='...', # Default None
+ algorithm='HS256', # Default -> 'HS256', accepts ['HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512']
+ iss=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1)
+ sub=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2)
+ aud=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3)
+ exp=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4)
+ nbf=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5)
+ iat=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.6)
+ auto_iat=False, # Default False (generate iat with current time) - (used only if IAT is None)
+ jti=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.7)
+ auto_jti=False, # Default False (generate jti with random hex) - (used only if JTI is None)
+ from_time=None # Default datetime.utcnow() - Base time from iss and nbf
+ payload={} # Your data
+ ).encode()
+
+ payload = JwtDecode(
+ token='...'
+ verify_iss=False, # Default False (verify jwt iss)
+ verify_aud=False, # Default False (verify jwt aud)
+ verify_exp=False, # Default False (verify jwt exp)
+ verify_nbf=False, # Default False (verify jwt nbf)
+ verify_iat=False, # Default False (verify jwt iat)
+ leeway=0 # Default 0 (validate time leeway)
+ ).decode(
+ raise_except=False # Default False (check `jwt.exceptions` for available exceptions)
+ )
+ ```
+
+# Usage (Django):
+
+OBS: This require `Django` and `Django Rest Framework` to work.
+
+1. Add to your `INSTALLED_APPS`, in `settings.py`:
+ ```
+ INSTALLED_APPS = [
+ ...
+ 'jwt_utils.django',
+ ...
+ ]
+ ```
+
+1. Add this configuration on `settings.py`:
+ ```
+ from datetime import timedelta
+ ...
+
+ JWT_UTILS = {
+ # all settings with None or False are ignored by default.
+
+ # Generating Jwt
+ 'SIGNING_KEY': settings.SECRET_KEY, # Default -> settings.SECRET_KEY
+ 'ALGORITHM': 'HS256', # Default -> 'HS256', accepts ['HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512']
+ 'ISSUER': 'myapp', # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1)
+ 'SUBJECT': None, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2)
+ 'AUDIENCE': ['web', 'mobile'], # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3)
+ 'EXPIRATION': timedelta(minutes=20), # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4)
+ 'NOT_BEFORE': timedelta(seconds=0), # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5)
+ 'IAT': None, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.6)
+ 'AUTO_IAT': True, Auto generate IAT claim (used only if IAT is None)
+ 'JTI': True, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.7)
+ 'AUTO_JTI': True, Auto generate JTI claim (used only if JTI is None)
+
+ # Checking Jwt
+ 'VERIFY_ISSUER': True, # Default `ISSUER is not None`
+ 'VERIFY_AUDIENCE': True, # Default `AUDIENCE is not None`
+ 'VERIFY_EXPIRATION': True, # Default `EXPIRATION is not None`
+ 'VERIFY_NOT_BEFORE': True, # Default `NOT_BEFORE is not None`
+ 'VERIFY_IAT': True, # Default `IAT is not None or AUTO_IAT`
+ 'VERIFY_MAX_LEEWAY': 0, # Default 0, validate time leeway
+ }
+ ```
+
+1. In your file:
+ ```
+ from jwt_utils.django import JwtEncode, JwtDecode
+ ...
+
+ token = JwtEncode(payload={}).encode()
+
+ payload = JwtDecode(token).decode(
+ raise_except=False # Default False (check `jwt.exceptions` for available exceptions)
+ )
+ ```
+
+%package help
+Summary: Development documents and examples for pyjwt-utils
+Provides: python3-pyjwt-utils-doc
+%description help
+PyJwt Utils
+=
+PyJwt-Utils is a wrapper to facility your token encode/decode.
+
+If you use or like the project, click `Star` and `Watch` to generate metrics and i evaluate project continuity.
+
+# Install:
+ pip install pyjwt-utils
+
+# Usage:
+1. In your file:
+ ```
+ from jwt_utils.django import JwtEncode, JwtDecode
+ ...
+
+ token = JwtEncode(
+ signing_key='...', # Default None
+ algorithm='HS256', # Default -> 'HS256', accepts ['HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512']
+ iss=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1)
+ sub=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2)
+ aud=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3)
+ exp=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4)
+ nbf=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5)
+ iat=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.6)
+ auto_iat=False, # Default False (generate iat with current time) - (used only if IAT is None)
+ jti=None, # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.7)
+ auto_jti=False, # Default False (generate jti with random hex) - (used only if JTI is None)
+ from_time=None # Default datetime.utcnow() - Base time from iss and nbf
+ payload={} # Your data
+ ).encode()
+
+ payload = JwtDecode(
+ token='...'
+ verify_iss=False, # Default False (verify jwt iss)
+ verify_aud=False, # Default False (verify jwt aud)
+ verify_exp=False, # Default False (verify jwt exp)
+ verify_nbf=False, # Default False (verify jwt nbf)
+ verify_iat=False, # Default False (verify jwt iat)
+ leeway=0 # Default 0 (validate time leeway)
+ ).decode(
+ raise_except=False # Default False (check `jwt.exceptions` for available exceptions)
+ )
+ ```
+
+# Usage (Django):
+
+OBS: This require `Django` and `Django Rest Framework` to work.
+
+1. Add to your `INSTALLED_APPS`, in `settings.py`:
+ ```
+ INSTALLED_APPS = [
+ ...
+ 'jwt_utils.django',
+ ...
+ ]
+ ```
+
+1. Add this configuration on `settings.py`:
+ ```
+ from datetime import timedelta
+ ...
+
+ JWT_UTILS = {
+ # all settings with None or False are ignored by default.
+
+ # Generating Jwt
+ 'SIGNING_KEY': settings.SECRET_KEY, # Default -> settings.SECRET_KEY
+ 'ALGORITHM': 'HS256', # Default -> 'HS256', accepts ['HS256', 'HS384', 'HS512', 'RS256', 'RS384', 'RS512']
+ 'ISSUER': 'myapp', # Default None -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.1)
+ 'SUBJECT': None, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.2)
+ 'AUDIENCE': ['web', 'mobile'], # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.3)
+ 'EXPIRATION': timedelta(minutes=20), # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.4)
+ 'NOT_BEFORE': timedelta(seconds=0), # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.5)
+ 'IAT': None, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.6)
+ 'AUTO_IAT': True, Auto generate IAT claim (used only if IAT is None)
+ 'JTI': True, # Default -> None (https://datatracker.ietf.org/doc/html/rfc7519#section-4.1.7)
+ 'AUTO_JTI': True, Auto generate JTI claim (used only if JTI is None)
+
+ # Checking Jwt
+ 'VERIFY_ISSUER': True, # Default `ISSUER is not None`
+ 'VERIFY_AUDIENCE': True, # Default `AUDIENCE is not None`
+ 'VERIFY_EXPIRATION': True, # Default `EXPIRATION is not None`
+ 'VERIFY_NOT_BEFORE': True, # Default `NOT_BEFORE is not None`
+ 'VERIFY_IAT': True, # Default `IAT is not None or AUTO_IAT`
+ 'VERIFY_MAX_LEEWAY': 0, # Default 0, validate time leeway
+ }
+ ```
+
+1. In your file:
+ ```
+ from jwt_utils.django import JwtEncode, JwtDecode
+ ...
+
+ token = JwtEncode(payload={}).encode()
+
+ payload = JwtDecode(token).decode(
+ raise_except=False # Default False (check `jwt.exceptions` for available exceptions)
+ )
+ ```
+
+%prep
+%autosetup -n pyjwt-utils-1.0.4
+
+%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-pyjwt-utils -f filelist.lst
+%dir %{python3_sitelib}/*
+
+%files help -f doclist.lst
+%{_docdir}/*
+
+%changelog
+* Tue Jun 20 2023 Python_Bot <Python_Bot@openeuler.org> - 1.0.4-1
+- Package Spec generated