Skip to content

Commit

Permalink
fixed typo errors in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
eadwinCode committed Jul 9, 2024
1 parent 763503d commit 7f8a286
Show file tree
Hide file tree
Showing 7 changed files with 113 additions and 130 deletions.
42 changes: 23 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@

## Abstract

Ninja JWT is JSON Web Token plugin for Django-Ninja. The library is a fork of [Simple JWT](https://github.com/jazzband/djangorestframework-simplejwt) by Jazzband, a popular JWT plugin for [Django REST Framework](http://www.django-rest-framework.org).
Ninja JWT is a JSON Web Token (JWT) plugin for Django-Ninja.
This library is a fork of [Simple JWT](https://github.com/jazzband/djangorestframework-simplejwt) by Jazzband,
a widely-used JWT plugin for the [Django REST Framework](http://www.django-rest-framework.org).

#### Notice
This library does not fix any issues from the source SIMPLE JWT.
It only added support for Django-Ninja and removes DRF dependencies. And time after time, subsequent updates from SIMPLE JWT will reflect here.

For full documentation, [visit](https://eadwincode.github.io/django-ninja-jwt/).
This library does not address any issues present in the original SIMPLE JWT.
It only adds support for Django-Ninja and removes dependencies on DRF.
Subsequent updates from SIMPLE JWT will be reflected here over time.

For full documentation, [visit this page](https://eadwincode.github.io/django-ninja-jwt/).
#### Requirements
- Python >= 3.6
- Django >= 2.1
Expand All @@ -28,41 +31,40 @@ For full documentation, [visit](https://eadwincode.github.io/django-ninja-jwt/).
Checkout this sample project: https://github.com/eadwinCode/bookstoreapi


Installation
============
## Installation

Ninja JWT can be installed with pip:

pip install django-ninja-jwt
```shell
pip install django-ninja-jwt
```

Also, you need to register `NinjaJWTDefaultController` controller to your Django-Ninja api.
You also need to register the `NinjaJWTDefaultController` controller to your Django-Ninja API:

```python
from ninja_jwt.controller import NinjaJWTDefaultController
from ninja_extra import NinjaExtraAPI

api = NinjaExtraAPI()
api.register_controllers(NinjaJWTDefaultController)

```

The `NinjaJWTDefaultController` comes with three routes `obtain_token`, `refresh_token` and `verify_token`.
It is a combination of two subclasses `TokenVerificationController` and `TokenObtainPairController`.
If you wish to customize these routes, you can inherit from these controllers and change its implementation
The `NinjaJWTDefaultController` includes three routes: `obtain_token`, `refresh_token`, and `verify_token`.
It combines two subclasses, `TokenVerificationController` and `TokenObtainPairController`.
If you want to customize these routes, you can inherit from these controllers and modify their implementation:

```python
from ninja_extra import api_controller
from ninja_jwt.controller import TokenObtainPairController

@api_controller('token', tags=['Auth'])
class MyCustomController(TokenObtainPairController):
"""obtain_token and refresh_token only"
...
"""obtain_token and refresh_token only"""
...
api.register_controllers(MyCustomController)
```

If you wish to use localizations/translations, simply add `ninja_jwt` to
`INSTALLED_APPS`.
To use localizations/translations, add `ninja_jwt` to your `INSTALLED_APPS`:

```python
INSTALLED_APPS = [
Expand All @@ -73,10 +75,12 @@ INSTALLED_APPS = [
```

## Using Ninja Router
Also, if you are not interested in following NinjaExtra methodology, check out this doc on how to use `Ninja-JWT` with `Django-Ninja` [here](https://eadwincode.github.io/django-ninja-jwt/customizing_token_claims/#use-django-ninja-router)

Usage
=====
If you prefer not to follow the NinjaExtra methodology,
refer to this [documentation](https://eadwincode.github.io/django-ninja-jwt/customizing_token_claims/#use-django-ninja-router)
on how to use `Ninja-JWT` with `Django-Ninja Router`.

## Usage

To verify that Ninja JWT is working, you can use curl to issue a couple
of test requests:
Expand Down
7 changes: 3 additions & 4 deletions docs/auth_integration.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
Ninja JWT uses Django Ninja `HttpBearer` as a way to authenticate users reaching your api endpoint.
Authenticated user can be found in `request.user` or `request.auth`

### Route Authentication - Class Based
### Route AuthenticationClass Based

```python
from ninja_extra import api_controller, route
Expand All @@ -15,7 +15,7 @@ class MyController:
...
```

### Route Authentication - Function Based
### Route AuthenticationFunction Based

```python
from ninja import router
Expand All @@ -28,8 +28,7 @@ def some_endpoint(request):
...
```

Custom Auth Implement
-------
## Custom Auth Implementation
If you wish to use a different implementation of `JWTAuth`, then you need to inherit from `JWTBaseAuthentication`.
Please read more on [Django Ninja - Authentication](https://django-ninja.rest-framework.com/tutorial/authentication/), if you want to use a different approach that is not `bearer`.

Expand Down
6 changes: 3 additions & 3 deletions docs/customizing_token_claims.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ views, create a subclass for the desired controller as well as a subclass for
its corresponding serializer. Here\'s an example :

!!! info
if you are interested in Asynchronous version of the class, use `AsyncNinjaJWTDefaultController` and `AsyncNinjaJWTSlidingController`.
Also note, it's only available for Django versions that supports asynchronous actions.
if you are interested in an Asynchronous version of the class, use `AsyncNinjaJWTDefaultController` and `AsyncNinjaJWTSlidingController`.
Also note, it's only available for Django versions that support asynchronous actions.

```python
from ninja_jwt.schema import TokenObtainPairInputSchema
Expand Down Expand Up @@ -46,7 +46,7 @@ As with the standard controller, you\'ll also need to include register the contr

#### Use Django Ninja Router

If you interested in using functions rather than classes, then you are also covered.
If you are interested in using functions rather than classes, then you are also covered.
Here is an example

```python
Expand Down
14 changes: 9 additions & 5 deletions docs/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,13 @@ INSTALLED_APPS = [
]
```
Usage
=====
## Using Ninja Router
If you prefer not to follow the NinjaExtra methodology,
refer to this [documentation](https://eadwincode.github.io/django-ninja-jwt/customizing_token_claims/#use-django-ninja-router)
on how to use `Ninja-JWT` with `Django-Ninja Router`.
## Usage
To verify that Ninja JWT is working, you can use curl to issue a couple
of test requests:
Expand Down Expand Up @@ -96,8 +101,7 @@ curl \
{"access":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoiYWNjZX...", "refresh":"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJ1c2VyX3BrIjoxLCJ0b2tlbl90eXBlIjoicmVm..."}
```
Cryptographic Dependencies (Optional)
-------------------------------------
## Cryptographic Dependencies (Optional)
If you are planning on encoding or decoding tokens using certain digital
signature algorithms (i.e. RSA and ECDSA; visit PyJWT for other algorithms), you will need to install the
Expand All @@ -107,7 +111,7 @@ extra in the `django-ninja-jwt` requirement:
pip install django-ninja-jwt[crypto]
The `django-ninja-jwt[crypto]` format is recommended in requirements
The `django-ninja-jwt[crypto]` format is recommended in requirement
files in projects using `Ninja JWT`, as a separate `cryptography` requirement
line may later be mistaken for an unused requirement and removed.
[cryptography](https://cryptography.io)
23 changes: 11 additions & 12 deletions docs/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,17 @@
[![PyPI version](https://img.shields.io/pypi/djversions/django-ninja-jwt.svg)](https://pypi.python.org/pypi/django-ninja-jwt)
[![Downloads](https://static.pepy.tech/personalized-badge/django-ninja-jwt?period=month&units=international_system&left_color=black&right_color=yellow&left_text=Downloads)](https://pepy.tech/project/django-ninja-jwt)

A JSON Web Token authentication plugin for the [Django Ninja REST Framework](https://github.com/vitalik/django-ninja).
## Introduction

------------------------------------------------------------------------
The Ninja JWT plugin offers JSON Web Token (JWT)
authentication for [Django Ninja](https://github.com/vitalik/django-ninja).
Designed to handle common JWT use cases,
it provides a robust authentication backend with a practical set of default features.
Additionally, Ninja JWT is highly extensible, allowing developers to add custom features as needed.

Ninja JWT provides a JSON Web Token authentication backend for the
Django Ninja REST Framework. It aims to cover the most common use cases of
JWTs by offering a conservative set of default features. It also aims to
be easily extensible in case a desired feature is not present.

Acknowledgments
------

This project borrows code from the [SIMPLE JWT](https://github.com/jazzband/djangorestframework-simplejwt) to implement Json Web Token for Django Ninja REST Framework.
However, I have included SIMPLE JWT license to the `license` folder.
## Acknowledgments

This project utilizes code from [SIMPLE JWT](https://github.com/jazzband/djangorestframework-simplejwt)
to implement JSON Web Token
(JWT) for the Django Ninja REST Framework.
The SIMPLE JWT license is included in the `license` folder.
Loading

0 comments on commit 7f8a286

Please sign in to comment.