Django는 사용자 인증 시스템을 지원합니다. 이 시스템은 사용자 계정, 그룹, 권한과 쿠키 기반의 사용자 세션을 다룹니다. 문서의 이 섹션은 기본 구현이 어떻게 별도 설정 없이(out of the box) 작동하는지를 설명하고, 어떻게 프로젝트의 요구조건에 맞도록 Django 인증을 확장하고 커스터마이징하는지 또한 설명합니다.
Django authentication 시스템은 인증과 권한부여를 모두 처리합니다. 요약하자면, 인증은 사용자가 누구인지를 판별하고, 권한부여는 인증된 사용자가 어떤 일을 할 수 있는지 결정합니다. 여기에 인증이라는 개념이 두 작업에 모두 쓰이게 됩니다.
Auth 시스템은 다음과 같이 구성되어 있습니다:
The authentication system in Django aims to be very generic and doesn’t provide some features commonly found in web authentication systems. Solutions for some of these common problems have been implemented in third-party packages:
Authentication support is bundled as a Django contrib module in
django.contrib.auth
. By default, the required configuration is already
included in the settings.py
generated by django-admin
startproject
, these consist of two items listed in your
INSTALLED_APPS
setting:
'django.contrib.auth'
contains the core of the authentication framework,
and its default models.'django.contrib.contenttypes'
is the Django content type system, which allows permissions to be associated with
models you create.and these items in your MIDDLEWARE
setting:
SessionMiddleware
manages
sessions across requests.AuthenticationMiddleware
associates
users with requests using sessions.With these settings in place, running the command manage.py migrate
creates
the necessary database tables for auth related models and permissions for any
models defined in your installed apps.
12월 04, 2023