Skip to content
This repository has been archived by the owner on Dec 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from Menda/general-fixes
Browse files Browse the repository at this point in the history
General fixes and version upgrades
  • Loading branch information
ybekdemir authored Aug 21, 2018
2 parents e2f89e7 + 7e50951 commit db3353b
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 12 deletions.
29 changes: 20 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,19 @@ Add to your pip requirements:
git+https://github.com/Humanitec/django-oauth-toolkit-jwt#egg=django-oauth-toolkit-jwt
```

Generate keys
-------------

In order to generate a RS256 (RSA Signature with SHA-256) public and private
keys, execute the following:

```
$ ssh-keygen -t rsa -b 4096 -f jwtRS256.key # don't add passphrase
$ openssl rsa -in jwtRS256.key -pubout -outform PEM -out jwtRS256.key.pub
$ cat jwtRS256.key
$ cat jwtRS256.key.pub
```


Producer configuration
----------------------
Expand Down Expand Up @@ -75,8 +88,8 @@ AUTHENTICATION_BACKENDS = (
```

Now we need to set up a `JWT_ISSUER` variable in our config, which will be the
name of the issuer. Also you will create a RSA private key for it and will
store it in a `JWT_PRIVATE_KEY_RSA_<JWT_ISSUER>` variable \*. For example:
name of the issuer. Take the RSA256 private key that we genreated before
and store it in a `JWT_PRIVATE_KEY_RSA_<JWT_ISSUER>` variable \*. For example:


```
Expand Down Expand Up @@ -142,7 +155,7 @@ REST_FRAMEWORK = {
}
```

Also, you will need to add to the settings every public RSA key of all the
Also, you will need to add to the settings every public RSA256 key of all the
possible token issuers using a variable `JWT_PUBLIC_KEY_RSA_<JWT_ISSUER>`:

```
Expand All @@ -155,14 +168,12 @@ hTZAZmJhid2o/+ya/28muuoQgknEoJz32bKeWuYZrFkRKUrGFnlxHwIDAQAB
"""
```

By default authentication will be enabled, use `JWT_AUTH_DISABLED` setting variable to disable that feature:
By default authentication will be enabled, use `JWT_AUTH_DISABLED` setting
variable to disable that feature:

```
#settings.py
# Default JWT_AUTH_DISABLED=False
JWT_AUTH_DISABLED=True
# settings.py
JWT_AUTH_DISABLED = True
```


Expand Down
2 changes: 1 addition & 1 deletion oauth2_provider_jwt/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,5 +66,5 @@ def decode_jwt(jwt_value):
raise ImproperlyConfigured('Missing setting {}'.format(
public_key_name))

decoded = jwt.decode(jwt_value, public_key, algorithms='RS256')
decoded = jwt.decode(jwt_value, public_key, algorithms=['RS256'])
return decoded
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
cryptography>=2.2.2,<2.3
cryptography>=2.3.1,<2.4
PyJWT>=1.6.4,<1.7
3 changes: 2 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
envlist = {py36,py27}-django{111, 20},flake8
envlist = {py36,py27}-django{111, 20, 21},flake8

[pytest]
django_find_project = false
Expand All @@ -13,6 +13,7 @@ deps =
-r{toxinidir}/requirements.txt
django111: Django<1.12
django20: Django<2.1
django21: Django<2.2
django-oauth-toolkit>=1.1.2,<1.2
djangorestframework>=3.7,<3.8
pyjwt>=1.6.4,<1.7
Expand Down

0 comments on commit db3353b

Please sign in to comment.