{"title":"Django でのユーザー認証","version":"1.11","locale":"ja","docname":"topics/auth/index","url":"/ja/1.11/topics/auth/","canonical":"https://djangodocs.dev/ja/1.11/topics/auth/","summary":"Django はユーザー認証システムを搭載しています。ユーザーアカウント、グループ、パーミッション、そしてCookieベースのユーザーセッションを制御します。","html":"<h1>Django でのユーザー認証<a class=\"heading-anchor\" href=\"#user-authentication-in-django\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<div class=\"toctree-wrapper compound\">\n</div>\n<p id=\"module-django.contrib.auth\">Django はユーザー認証システムを搭載しています。ユーザーアカウント、グループ、パーミッション、そしてCookieベースのユーザーセッションを制御します。このドキュメントのこのセクションでは、デフォルトの実装がどう機能するか、またあなたのプロジェクトのニーズに対応させるための <a class=\"reference internal\" href=\"/ja/1.11/topics/auth/customizing/\"><span class=\"doc\">拡張とカスタマイズ</span></a> の方法を説明しています。</p>\n<section id=\"overview\">\n<h2>概要<a class=\"heading-anchor\" href=\"#overview\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Django の認証システムは、認証と権限の両方を扱います。簡単に言うと、認証はユーザーが誰であるかを立証し、権限は立証されたユーザーが何をすることが許されているかを決定します。ここでは、認証という用語は両方のタスクを指すために使われます。</p>\n<p>認証システムを構成するものは以下の通りです:</p>\n<ul class=\"simple\">\n<li><p>ユーザ</p></li>\n<li><p>パーミッション: ユーザが特定のタスクを実行できるかどうかを指定するバイナリ (yes/no) フラグ</p></li>\n<li><p>グループ: 複数のユーザーにラベルとパーミッションを付与する一般的な方法</p></li>\n<li><p>設定変更可能なパスワードハッシュシステム</p></li>\n<li><p>ユーザーログインのためのフォームやビューツール、もしくは内容の制限</p></li>\n<li><p>プラガブルなバックエンドシステム</p></li>\n</ul>\n<p>Django の認証システムは一般的であることを狙いとしており、ウェブ上の認証システムで見られるようないくつかの機能を有していません。これらに共通する問題の解決策は、サードパーティのパッケージにて実装されます。</p>\n<ul class=\"simple\">\n<li><p>パスワード強度のチェック</p></li>\n<li><p>ログイン試行数の制限</p></li>\n<li><p>サードパーティに対する認証 (OAuthなど)</p></li>\n</ul>\n</section>\n<section id=\"installation\">\n<h2>インストール<a class=\"heading-anchor\" href=\"#installation\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p>Authentication support is bundled as a Django contrib module in\n<code class=\"docutils literal notranslate\">django.contrib.auth</code>. By default, the required configuration is already\nincluded in the <code class=\"file docutils literal notranslate\">settings.py</code> generated by <a class=\"reference internal\" href=\"/ja/1.11/ref/django-admin/#django-admin-startproject\"><code class=\"xref std std-djadmin docutils literal notranslate\">django-admin\nstartproject</code></a>, these consist of two items listed in your\n<a class=\"reference internal\" href=\"/ja/1.11/ref/settings/#std-setting-INSTALLED_APPS\"><code class=\"xref std std-setting docutils literal notranslate\">INSTALLED_APPS</code></a> setting:</p>\n<ol class=\"arabic simple\">\n<li><p><code class=\"docutils literal notranslate\">'django.contrib.auth'</code> contains the core of the authentication framework,\nand its default models.</p></li>\n<li><p><code class=\"docutils literal notranslate\">'django.contrib.contenttypes'</code> is the Django <a class=\"reference internal\" href=\"/ja/1.11/ref/contrib/contenttypes/\"><span class=\"doc\">content type system</span></a>, which allows permissions to be associated with\nmodels you create.</p></li>\n</ol>\n<p>and these items in your <a class=\"reference internal\" href=\"/ja/1.11/ref/settings/#std-setting-MIDDLEWARE\"><code class=\"xref std std-setting docutils literal notranslate\">MIDDLEWARE</code></a> setting:</p>\n<ol class=\"arabic simple\">\n<li><p><a class=\"reference internal\" href=\"/ja/1.11/ref/middleware/#django.contrib.sessions.middleware.SessionMiddleware\" title=\"django.contrib.sessions.middleware.SessionMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">SessionMiddleware</code></a> manages\n<a class=\"reference internal\" href=\"/ja/1.11/topics/http/sessions/\"><span class=\"doc\">sessions</span></a> across requests.</p></li>\n<li><p><a class=\"reference internal\" href=\"/ja/1.11/ref/middleware/#django.contrib.auth.middleware.AuthenticationMiddleware\" title=\"django.contrib.auth.middleware.AuthenticationMiddleware\"><code class=\"xref py py-class docutils literal notranslate\">AuthenticationMiddleware</code></a> associates\nusers with requests using sessions.</p></li>\n</ol>\n<p>With these settings in place, running the command <code class=\"docutils literal notranslate\">manage.py migrate</code> creates\nthe necessary database tables for auth related models and permissions for any\nmodels defined in your installed apps.</p>\n</section>\n<section id=\"usage\">\n<h2>使い方<a class=\"heading-anchor\" href=\"#usage\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<p><a class=\"reference internal\" href=\"/ja/1.11/topics/auth/default/\"><span class=\"doc\">Using Django's default implementation</span></a></p>\n<ul class=\"simple\">\n<li><p><a class=\"reference internal\" href=\"/ja/1.11/topics/auth/default/#user-objects\"><span class=\"std std-ref\">Working with User objects</span></a></p></li>\n<li><p>パーミッションと認可</p></li>\n<li><p><a class=\"reference internal\" href=\"/ja/1.11/topics/auth/default/#auth-web-requests\"><span class=\"std std-ref\">Authentication in web requests</span></a></p></li>\n<li><p><a class=\"reference internal\" href=\"/ja/1.11/topics/auth/default/#auth-admin\"><span class=\"std std-ref\">Managing users in the admin</span></a></p></li>\n</ul>\n<p><a class=\"reference internal\" href=\"/ja/1.11/ref/contrib/auth/\"><span class=\"doc\">API reference for the default implementation</span></a></p>\n<p><a class=\"reference internal\" href=\"/ja/1.11/topics/auth/customizing/\"><span class=\"doc\">Customizing Users and authentication</span></a></p>\n<p><a class=\"reference internal\" href=\"/ja/1.11/topics/auth/passwords/\"><span class=\"doc\">Password management in Django</span></a></p>\n</section>","rootId":"user-authentication-in-django","toc":[{"title":"概要","anchor":"overview","children":[]},{"title":"インストール","anchor":"installation","children":[]},{"title":"使い方","anchor":"usage","children":[]}],"breadcrumbs":[{"docname":"topics/index","title":"Django を使う","url":"/ja/1.11/topics/"}],"prev":{"docname":"topics/testing/advanced","title":"Advanced testing topics","url":"/ja/1.11/topics/testing/advanced/"},"next":{"docname":"topics/auth/default","title":"Djangoの認証システムを使用する","url":"/ja/1.11/topics/auth/default/"},"formats":{"html":"/ja/1.11/topics/auth/","markdown":"/ja/1.11/topics/auth.md","json":"/ja/1.11/topics/auth.json"},"source":"https://github.com/django/django/blob/stable/1.11.x/docs/topics/auth/index.txt","official":"https://docs.djangoproject.com/ja/1.11/topics/auth/","inVersions":["6.1","6.0","5.2","5.1","5.0","4.2","4.1","4.0","3.2","3.1","3.0","2.2","2.1","2.0","1.11","1.10","1.9"],"inLocales":["en","fr","ja","id","pt-br","ko","es","el","pl"]}