{"title":"Conas fíordheimhniú i gcoinne bunachar sonraí úsáideoirí Django ó Apache","version":"6.0","locale":"ga","docname":"howto/deployment/wsgi/apache-auth","url":"/ga/6.0/howto/deployment/wsgi/apache-auth/","canonical":"https://djangodocs.dev/ga/6.0/howto/deployment/wsgi/apache-auth/","summary":"Since keeping multiple authentication databases in sync is a common problem when dealing with Apache, you can configure Apache to authenticate against Django's…","html":"<h1>Conas fíordheimhniú i gcoinne bunachar sonraí úsáideoirí Django ó Apache<a class=\"heading-anchor\" href=\"#how-to-authenticate-against-django-s-user-database-from-apache\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h1>\n<p>Since keeping multiple authentication databases in sync is a common problem\nwhen dealing with Apache, you can configure Apache to authenticate against\nDjango's <a class=\"reference internal\" href=\"/ga/6.0/topics/auth/\"><span class=\"doc\">authentication system</span></a> directly. This\nrequires Apache version &gt;= 2.2 and <code class=\"docutils literal notranslate\"><span class=\"pre\">mod_wsgi</span></code> &gt;= 2.0. For example, you could:</p>\n<ul class=\"simple\">\n<li><p>Freastal ar chomhaid statacha/meán go díreach ó Apache d'úsáideoirí fíordheimhnithe amháin.</p></li>\n<li><p>Fíordheimhnigh rochtain ar stór <a class=\"reference external\" href=\"https://subversion.apache.org/\">Subversion</a> i gcoinne úsáideoirí Django le cead áirithe.</p></li>\n<li><p>Lig d'úsáideoirí áirithe ceangal le scair WebDAV a cruthaíodh le <a class=\"reference external\" href=\"https://httpd.apache.org/docs/current/mod/mod_dav.html\">mod_dav</a>.</p></li>\n</ul>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>Má tá a:ref: samhail úsáideora saincheaptha &lt;auth-custom-user&gt;`suiteáilte agat agus má theastaíonn uait an láimhseálaí auth réamhshocraithe seo a úsáid, caithfidh sé tacú le tréith ``is_active`. Más mian leat údarú grúpbhunaithe a úsáid, caithfidh caidreamh ainmnithe 'grúpaí' a bheith ag d'úsáideoir saincheaptha, ag tagairt do réad gaolmhar a bhfuil réimse 'ainm' aige. Is féidir leat do láimhseálaí auth mod_wsgi saincheaptha féin a shonrú mura féidir le do saincheaptha cloí leis na riachtanais seo.</p>\n</aside>\n<section id=\"authentication-with-mod-wsgi\">\n<h2>Fíordheimhniú le <code class=\"docutils literal notranslate\"><span class=\"pre\">mod_wsgi</span></code><a class=\"heading-anchor\" href=\"#authentication-with-mod-wsgi\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h2>\n<aside class=\"admonition admonition-note\" role=\"note\">\n<p class=\"admonition-title\">Note</p>\n<p>Le húsáid <code class=\"docutils literal notranslate\"><span class=\"pre\">WSGIApplicationGroup</span> <span class=\"pre\">%{GLOBAL}</span></code> sna cumraíochtaí thíos, glacann sé leis nach bhfuil ach feidhmchlár Django amháin á rith ag do shampla Apache. Má tá níos mó ná feidhmchlár Django amháin á rith agat, féach le do thoil don rannán <a class=\"reference external\" href=\"https://modwsgi.readthedocs.io/en/develop/user-guides/configuration-guidelines.html#defining-application-groups\">Grúpaí Feidhmchláir a Shainmhíniú</a> sna doiciméid mod_wsgi chun tuilleadh eolais a fháil faoin socrú seo.</p>\n</aside>\n<p>Déan cinnte go bhfuil mod_wsgi suiteáilte agus gníomhachtaithe agus gur lean tú na céimeanna chun bunú:doc: Apache le mod_&lt;/howto/deployment/wsgi/modwsgi&gt; wsgi.</p>\n<p>Ansin, cuir do chumraíocht Apache in eagar chun suíomh a chur leis nach dteastaíonn uait nach mbeidh ach úsáideoirí fíordheimhnithe in ann a fheiceáil:</p>\n<div class=\"code-block\" data-language=\"apache\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Apache</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Apache code\"><code><span class=\"nb\">WSGIScriptAlias</span><span class=\"w\"> </span>/<span class=\"w\"> </span><span class=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n<span class=\"nb\">WSGIPythonPath</span><span class=\"w\"> </span><span class=\"sx\">/path/to/mysite.com</span>\n\n<span class=\"nb\">WSGIProcessGroup</span><span class=\"w\"> </span>%{GLOBAL}\n<span class=\"nb\">WSGIApplicationGroup</span><span class=\"w\"> </span>%{GLOBAL}\n\n<span class=\"nt\">&lt;Location</span><span class=\"w\"> </span><span class=\"s\">&quot;/secret&quot;</span><span class=\"nt\">&gt;</span>\n<span class=\"w\">    </span><span class=\"nb\">AuthType</span><span class=\"w\"> </span>Basic\n<span class=\"w\">    </span><span class=\"nb\">AuthName</span><span class=\"w\"> </span><span class=\"s2\">&quot;Top Secret&quot;</span>\n<span class=\"w\">    </span><span class=\"nb\">Require</span><span class=\"w\"> </span>valid-user\n<span class=\"w\">    </span><span class=\"nb\">AuthBasicProvider</span><span class=\"w\"> </span>wsgi\n<span class=\"w\">    </span><span class=\"nb\">WSGIAuthUserScript</span><span class=\"w\"> </span><span class=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n<span class=\"nt\">&lt;/Location&gt;</span>\n</code></pre></div>\n<p>Insíonn an treoir <code class=\"docutils literal notranslate\"><span class=\"pre\">wsgiauthuserscript</span></code> do mod_wsgi an fheidhm <code class=\"docutils literal notranslate\"><span class=\"pre\">check_password</span></code> a fhorghníomhú i script wsgi sonraithe, ag dul ar aghaidh an ainm úsáideora agus an pasfhocal a fhaigheann sé ón pras. Sa sampla seo, tá an WSGIAuthUserScript` mar an gcéanna leis an <code class=\"docutils literal notranslate\"><span class=\"pre\">WSGIScriptalias</span></code> a shainmhíníonn d'iarratas:doc: atá cru&lt;/howto/deployment/wsgi/index&gt; thaithe ag django-admin startproject.</p>\n<aside class=\"admonition-using-apache-2-2-with-authentication admonition\">\n<p class=\"admonition-title\">Using Apache 2.2+ with authentication</p>\n<p>Déan cinnte go bhfuil mod_auth_basic` agus <code class=\"docutils literal notranslate\"><span class=\"pre\">mod_authz_user</span></code> luchtaithe.</p>\n<p>D'fhéadfaí iad seo a thiomsú go statach i Apache, nó b'fhéidir go mbeidh ort LoadModule a úsáid chun iad a luchtú go dinimiciúil i do httpd.conf`:</p>\n<div class=\"code-block\" data-language=\"apache\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Apache</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Apache code\"><code><span class=\"nb\">LoadModule</span><span class=\"w\"> </span>auth_basic_module<span class=\"w\"> </span>modules/mod_auth_basic.so\n<span class=\"nb\">LoadModule</span><span class=\"w\"> </span>authz_user_module<span class=\"w\"> </span>modules/mod_authz_user.so\n</code></pre></div>\n</aside>\n<p>Faoi dheireadh, cuir do script WSGI <code class=\"docutils literal notranslate\"><span class=\"pre\">mysite.wsgi</span></code> in eagar chun fíordheimhniú Apache a cheangal le meicníochtaí fíordheimhnithe do shuíomh tríd an fheidhm <code class=\"docutils literal notranslate\"><span class=\"pre\">check_password</span></code> a allmhairiú:</p>\n<div class=\"code-block\" data-language=\"default\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Code</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Code code\"><code><span class=\"kn\">import</span><span class=\"w\"> </span><span class=\"nn\">os</span>\n\n<span class=\"n\">os</span><span class=\"o\">.</span><span class=\"n\">environ</span><span class=\"p\">[</span><span class=\"s2\">&quot;DJANGO_SETTINGS_MODULE&quot;</span><span class=\"p\">]</span> <span class=\"o\">=</span> <span class=\"s2\">&quot;mysite.settings&quot;</span>\n\n<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.contrib.auth.handlers.modwsgi</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">check_password</span>\n\n<span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.core.handlers.wsgi</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">WSGIHandler</span>\n\n<span class=\"n\">application</span> <span class=\"o\">=</span> <span class=\"n\">WSGIHandler</span><span class=\"p\">()</span>\n</code></pre></div>\n<p>Beidh iarratais a thosaíonn le <code class=\"docutils literal notranslate\"><span class=\"pre\">/rúdaí/</span></code> éilíonn úsáideoir a fhíordheimhniú anois.</p>\n<p>Soláthraíonn mod_wsgi <a class=\"reference external\" href=\"https://modwsgi.readthedocs.io/en/develop/user-guides/access-control-mechanisms.html\">doiciméadú meicníochtaí rialaithe rochtaine</a> sonraí agus faisnéis bhreise faoi mhodhanna malartacha fíordheimhnithe.</p>\n<section id=\"authorization-with-mod-wsgi-and-django-groups\">\n<h3>Údarú le grúpaí mod_wsgi` agus Django<a class=\"heading-anchor\" href=\"#authorization-with-mod-wsgi-and-django-groups\"><span class=\"visually-hidden\">Link to this heading</span><span aria-hidden=\"true\">#</span></a></h3>\n<p>cuireann mod_wsgi feidhmiúlacht ar fáil freisin chun suíomh ar leith a theorannú do bhaill ghrúpa.</p>\n<p>Sa chás seo, ba chóir go mbeadh cuma seo ar chumraíocht Apache:</p>\n<div class=\"code-block\" data-language=\"apache\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Apache</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Apache code\"><code><span class=\"nb\">WSGIScriptAlias</span><span class=\"w\"> </span>/<span class=\"w\"> </span><span class=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n\n<span class=\"nb\">WSGIProcessGroup</span><span class=\"w\"> </span>%{GLOBAL}\n<span class=\"nb\">WSGIApplicationGroup</span><span class=\"w\"> </span>%{GLOBAL}\n\n<span class=\"nt\">&lt;Location</span><span class=\"w\"> </span><span class=\"s\">&quot;/secret&quot;</span><span class=\"nt\">&gt;</span>\n<span class=\"w\">    </span><span class=\"nb\">AuthType</span><span class=\"w\"> </span>Basic\n<span class=\"w\">    </span><span class=\"nb\">AuthName</span><span class=\"w\"> </span><span class=\"s2\">&quot;Top Secret&quot;</span>\n<span class=\"w\">    </span><span class=\"nb\">AuthBasicProvider</span><span class=\"w\"> </span>wsgi\n<span class=\"w\">    </span><span class=\"nb\">WSGIAuthUserScript</span><span class=\"w\"> </span><span class=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n<span class=\"w\">    </span><span class=\"nb\">WSGIAuthGroupScript</span><span class=\"w\"> </span><span class=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n<span class=\"w\">    </span><span class=\"nb\">Require</span><span class=\"w\"> </span><span class=\"k\">group</span><span class=\"w\"> </span>secret-agents\n<span class=\"w\">    </span><span class=\"nb\">Require</span><span class=\"w\"> </span>valid-user\n<span class=\"nt\">&lt;/Location&gt;</span>\n</code></pre></div>\n<p>Chun tacú leis an treoir <code class=\"docutils literal notranslate\"><span class=\"pre\">WSGIAuthGroupScript</span></code>, ní mór don script WSGI céanna <code class=\"docutils literal notranslate\"><span class=\"pre\">mysite.wsgi</span></code> an fheidhm <code class=\"docutils literal notranslate\"><span class=\"pre\">groups_for_user</span></code> a iompórtáil freisin a thugann liosta grúpaí leis an úsáideoir ar leith.</p>\n<div class=\"code-block\" data-language=\"python\"><div class=\"code-block-toolbar\"><span class=\"code-block-language\">Python</span><button type=\"button\" class=\"copy-button\" data-copy hidden><span class=\"copy-button-label\">Copy</span></button></div><pre role=\"group\" tabindex=\"0\" aria-label=\"Python code\"><code><span class=\"kn\">from</span><span class=\"w\"> </span><span class=\"nn\">django.contrib.auth.handlers.modwsgi</span><span class=\"w\"> </span><span class=\"kn\">import</span> <span class=\"n\">check_password</span><span class=\"p\">,</span> <span class=\"n\">groups_for_user</span>\n</code></pre></div>\n<p>Éilíonn iarratais ar <code class=\"docutils literal notranslate\"><span class=\"pre\">/rúna/</span></code> anois an t-úsáideoir a bheith ina bhall den ghrúpa “gníomhairí rúnaimh”.</p>\n</section>\n</section>","rootId":"how-to-authenticate-against-django-s-user-database-from-apache","toc":[{"title":"Fíordheimhniú le mod_wsgi","anchor":"authentication-with-mod-wsgi","children":[{"title":"Údarú le grúpaí mod_wsgi` agus Django","anchor":"authorization-with-mod-wsgi-and-django-groups","children":[]}]}],"breadcrumbs":[{"docname":"howto/index","title":"Treoracha conas","url":"/ga/6.0/howto/"},{"docname":"howto/deployment/index","title":"Conas Django a imscaradh","url":"/ga/6.0/howto/deployment/"},{"docname":"howto/deployment/wsgi/index","title":"Conas a imscaradh le WSGI","url":"/ga/6.0/howto/deployment/wsgi/"}],"prev":{"docname":"howto/deployment/wsgi/modwsgi","title":"Conas Django a úsáid le Apache agus mod_wsgi","url":"/ga/6.0/howto/deployment/wsgi/modwsgi/"},"next":{"docname":"howto/deployment/asgi/index","title":"Conas a imscaradh le ASGI","url":"/ga/6.0/howto/deployment/asgi/"},"formats":{"html":"/ga/6.0/howto/deployment/wsgi/apache-auth/","markdown":"/ga/6.0/howto/deployment/wsgi/apache-auth.md","json":"/ga/6.0/howto/deployment/wsgi/apache-auth.json"},"source":"https://github.com/django/django/blob/stable/6.0.x/docs/howto/deployment/wsgi/apache-auth.txt","official":"https://docs.djangoproject.com/ga/6.0/howto/deployment/wsgi/apache-auth/","inVersions":["6.1","6.0","5.2"],"inLocales":["en","sv","zh-hans","ga","fr","ja","id","it","pt-br","ko","es","el","pl"]}