|
| 1 | +# Template Repository for DRF SimpleJWT Apps |
| 2 | + |
| 3 | +Initially created: 3 July 2020 |
| 4 | + |
| 5 | +TL;DR: Django server repository setup for SimpleJWT. Test user: `test` and pw `test`. |
| 6 | + |
| 7 | +--- |
| 8 | +### Example repositories |
| 9 | + |
| 10 | +- Android: [Andrew-Chen-Wang/mobile-auth-example](https://github.com/Andrew-Chen-Wang/mobile-auth-example) |
| 11 | +- iOS: [Andrew-Chen-Wang/mobile-auth-example](https://github.com/Andrew-Chen-Wang/mobile-auth-example) |
| 12 | + |
| 13 | +--- |
| 14 | +### Introduction |
| 15 | + |
| 16 | +This template repository is dedicated to generating |
| 17 | +a Django + DRF server with SimpleJWT already setup. |
| 18 | +The purpose of this is to easily create repositories |
| 19 | +that demonstrate clear usage of SimpleJWT. |
| 20 | + |
| 21 | +If you're not using a frontend framework like React |
| 22 | +or some kind of mobile device not using a web browser, |
| 23 | +then please use session authentication. I.e. if you're |
| 24 | +using plain HTML with Jinja 2 template tags, use the |
| 25 | +built-in session authentication middlewear as that |
| 26 | +is proven to be the safest and thus far never broken |
| 27 | +method of secure authentication. |
| 28 | + |
| 29 | +Note: this template repository is adopted from |
| 30 | +[Andrew-Chen-Wang/mobile-auth-example](https://github.com/Andrew-Chen-Wang/mobile-auth-example) |
| 31 | +for Android and iOS usage. The license is Apache 2.0 |
| 32 | +for that example repository. |
| 33 | + |
| 34 | +--- |
| 35 | +### Usage |
| 36 | + |
| 37 | +1. To generate a repository using this template, |
| 38 | +press "Use this template" (highlighted in green). |
| 39 | +Note, this will NOT create a fork of the repository. |
| 40 | +2. Create your git repository, connect via the ssh remote, and pull. |
| 41 | +3. `cd server` to get your terminal/cmd into the server directory. |
| 42 | +4. To run the server, create a virtual environment `virtualenv venv && source venv/bin/activate`, install packages `pip install -r requirements.txt` -- the requirements.txt file is inside the server subdirectory -- and do `python manage.py migrate && python manage.py runserver`. |
| 43 | + - Again, make sure when you do this, you are inside the server directory on your terminal/cmd. |
| 44 | + - On Windows, you should do `venv\Scripts\activate` instead of `source venv/bin/activate` |
| 45 | +5. If you're writing for an example repository, please create |
| 46 | +a new directory labeled with the name of the framework (e.g. jwt-ios), |
| 47 | +and add its `.gitignore`. Please use the |
| 48 | +[github/gitignore](https://github.com/github/gitignore) repository. |
| 49 | +Provide detailed instructions if necessary. |
| 50 | + |
| 51 | +A default user with the username `test` and password `test` have been created. |
| 52 | + |
| 53 | +This repository does not come with throttling, but **it is |
| 54 | +highly recommended that you add throttling to your entire |
| 55 | +project.** You can use a third-party package called |
| 56 | +Django-ratelimit or DRF's internal throttling mechanism. |
| 57 | +Django-ratelimit is more extensive -- covering Django views, |
| 58 | +as well -- and thus more supported by SimpleJWT. |
| 59 | + |
| 60 | +--- |
| 61 | +### License |
| 62 | + |
| 63 | +This repository is licensed under the |
| 64 | +[MIT License](https://github.com/SimpleJWT/drf-SimpleJWT-server-template/blob/master/LICENSE). |
0 commit comments