Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/fix_instance_check' into fix_ins…
Browse files Browse the repository at this point in the history
…tance_check
  • Loading branch information
954-Ivory committed Nov 22, 2022
2 parents 0d46e58 + c9b6b02 commit 4471c05
Show file tree
Hide file tree
Showing 85 changed files with 579 additions and 506 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- '3.8'
- '3.9'
- '3.10'
- '3.11'

steps:
- uses: actions/checkout@v3
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,8 @@ There is a live example API for testing purposes, [available here][sandbox].

# Requirements

* Python (3.6, 3.7, 3.8, 3.9, 3.10)
* Django (2.2, 3.0, 3.1, 3.2, 4.0, 4.1)
* Python 3.6+
* Django 4.1, 4.0, 3.2, 3.1, 3.0

We **highly recommend** and only officially support the latest patch release of
each Python and Django series.
Expand Down
28 changes: 14 additions & 14 deletions docs/api-guide/authentication.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,9 +173,9 @@ The `curl` command line tool may be useful for testing token authenticated APIs.

---

#### Generating Tokens
### Generating Tokens

##### By using signals
#### By using signals

If you want every user to have an automatically generated Token, you can simply catch the User's `post_save` signal.

Expand All @@ -199,9 +199,9 @@ If you've already created some users, you can generate tokens for all existing u
for user in User.objects.all():
Token.objects.get_or_create(user=user)

##### By exposing an api endpoint
#### By exposing an api endpoint

When using `TokenAuthentication`, you may want to provide a mechanism for clients to obtain a token given the username and password. REST framework provides a built-in view to provide this behaviour. To use it, add the `obtain_auth_token` view to your URLconf:
When using `TokenAuthentication`, you may want to provide a mechanism for clients to obtain a token given the username and password. REST framework provides a built-in view to provide this behavior. To use it, add the `obtain_auth_token` view to your URLconf:

from rest_framework.authtoken import views
urlpatterns += [
Expand All @@ -216,7 +216,7 @@ The `obtain_auth_token` view will return a JSON response when valid `username` a

Note that the default `obtain_auth_token` view explicitly uses JSON requests and responses, rather than using default renderer and parser classes in your settings.

By default, there are no permissions or throttling applied to the `obtain_auth_token` view. If you do wish to apply to throttle you'll need to override the view class,
By default, there are no permissions or throttling applied to the `obtain_auth_token` view. If you do wish to apply throttling you'll need to override the view class,
and include them using the `throttle_classes` attribute.

If you need a customized version of the `obtain_auth_token` view, you can do so by subclassing the `ObtainAuthToken` view class, and using that in your url conf instead.
Expand Down Expand Up @@ -248,9 +248,9 @@ And in your `urls.py`:
]


##### With Django admin
#### With Django admin

It is also possible to create Tokens manually through the admin interface. In case you are using a large user base, we recommend that you monkey patch the `TokenAdmin` class customize it to your needs, more specifically by declaring the `user` field as `raw_field`.
It is also possible to create Tokens manually through the admin interface. In case you are using a large user base, we recommend that you monkey patch the `TokenAdmin` class to customize it to your needs, more specifically by declaring the `user` field as `raw_field`.

`your_app/admin.py`:

Expand Down Expand Up @@ -289,7 +289,7 @@ If you're using an AJAX-style API with SessionAuthentication, you'll need to mak

**Warning**: Always use Django's standard login view when creating login pages. This will ensure your login views are properly protected.

CSRF validation in REST framework works slightly differently from standard Django due to the need to support both session and non-session based authentication to the same views. This means that only authenticated requests require CSRF tokens, and anonymous requests may be sent without CSRF tokens. This behaviour is not suitable for login views, which should always have CSRF validation applied.
CSRF validation in REST framework works slightly differently from standard Django due to the need to support both session and non-session based authentication to the same views. This means that only authenticated requests require CSRF tokens, and anonymous requests may be sent without CSRF tokens. This behavior is not suitable for login views, which should always have CSRF validation applied.


## RemoteUserAuthentication
Expand All @@ -299,15 +299,15 @@ environment variable.

To use it, you must have `django.contrib.auth.backends.RemoteUserBackend` (or a subclass) in your
`AUTHENTICATION_BACKENDS` setting. By default, `RemoteUserBackend` creates `User` objects for usernames that don't
already exist. To change this and other behaviour, consult the
already exist. To change this and other behavior, consult the
[Django documentation](https://docs.djangoproject.com/en/stable/howto/auth-remote-user/).

If successfully authenticated, `RemoteUserAuthentication` provides the following credentials:

* `request.user` will be a Django `User` instance.
* `request.auth` will be `None`.

Consult your web server's documentation for information about configuring an authentication method, e.g.:
Consult your web server's documentation for information about configuring an authentication method, for example:

* [Apache Authentication How-To](https://httpd.apache.org/docs/2.4/howto/auth.html)
* [NGINX (Restricting Access)](https://docs.nginx.com/nginx/admin-guide/security-controls/configuring-http-basic-authentication/)
Expand Down Expand Up @@ -338,7 +338,7 @@ If the `.authenticate_header()` method is not overridden, the authentication sch

The following example will authenticate any incoming request as the user given by the username in a custom request header named 'X-USERNAME'.

from django.contrib.auth.models import User
from django.contrib.auth.models import User
from rest_framework import authentication
from rest_framework import exceptions

Expand Down Expand Up @@ -369,7 +369,7 @@ The following third-party packages are also available.

The [Django OAuth Toolkit][django-oauth-toolkit] package provides OAuth 2.0 support and works with Python 3.4+. The package is maintained by [jazzband][jazzband] and uses the excellent [OAuthLib][oauthlib]. The package is well documented, and well supported and is currently our **recommended package for OAuth 2.0 support**.

#### Installation & configuration
### Installation & configuration

Install using `pip`.

Expand All @@ -396,7 +396,7 @@ The [Django REST framework OAuth][django-rest-framework-oauth] package provides

This package was previously included directly in the REST framework but is now supported and maintained as a third-party package.

#### Installation & configuration
### Installation & configuration

Install the package using `pip`.

Expand All @@ -418,7 +418,7 @@ HTTP Signature (currently a [IETF draft][http-signature-ietf-draft]) provides a

## Djoser

[Djoser][djoser] library provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation. The package works with a custom user model and uses token-based authentication. This is ready to use REST implementation of the Django authentication system.
[Djoser][djoser] library provides a set of views to handle basic actions such as registration, login, logout, password reset and account activation. The package works with a custom user model and uses token-based authentication. This is a ready to use REST implementation of the Django authentication system.

## django-rest-auth / dj-rest-auth

Expand Down
2 changes: 1 addition & 1 deletion docs/api-guide/content-negotiation.md
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ The default content negotiation class may be set globally, using the `DEFAULT_CO

You can also set the content negotiation used for an individual view, or viewset, using the `APIView` class-based views.

from myapp.negotiation import IgnoreClientContentNegotiation
from myapp.negotiation import IgnoreClientContentNegotiation
from rest_framework.response import Response
from rest_framework.views import APIView

Expand Down
Loading

0 comments on commit 4471c05

Please sign in to comment.