{"title":"Conas fíordheimhniú i gcoinne bunachar sonraí úsáideoirí Django ó Apache","version":"5.2","locale":"ga","docname":"howto/deployment/wsgi/apache-auth","url":"/ga/5.2/howto/deployment/wsgi/apache-auth/","canonical":"https://djangodocs.dev/ga/5.2/howto/deployment/wsgi/apache-auth/","summary":"Ós rud é gur fadhb choitianta í bunachair sonraí fíordheimhnithe iolracha a choinneáil i gcomhréir agus tú ag déileáil le Apache, is féidir leat Apache a…","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>Ós rud é gur fadhb choitianta í bunachair sonraí fíordheimhnithe iolracha a choinneáil i gcomhréir agus tú ag déileáil le Apache, is féidir leat Apache a chumrú chun fíordheimhniú i gcoinne Django: doc: córas fíordheimhniúcháin &lt;/topics/auth/index&gt; Éilíonn sé seo leagan Apache &gt; = 2.2 agus mod_wsgi &gt; = 2.0. Mar shampla, d'fhéadfá:</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/2.2/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\">mod_wsgi</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\">WSGIApplicationGroup %{GLOBAL}</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=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n<span class=\"nb\">WSGIPythonPath</span> <span class=\"sx\">/path/to/mysite.com</span>\n\n<span class=\"nb\">WSGIProcessGroup</span> %{GLOBAL}\n<span class=\"nb\">WSGIApplicationGroup</span> %{GLOBAL}\n\n<span class=\"nt\">&lt;Location</span> <span class=\"s\">&quot;/secret&quot;</span><span class=\"nt\">&gt;</span>\n    <span class=\"nb\">AuthType</span> Basic\n    <span class=\"nb\">AuthName</span> <span class=\"s2\">&quot;Top Secret&quot;</span>\n    <span class=\"nb\">Require</span> valid-user\n    <span class=\"nb\">AuthBasicProvider</span> wsgi\n    <span class=\"nb\">WSGIAuthUserScript</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\">wsgiauthuserscript</code> do mod_wsgi an fheidhm <code class=\"docutils literal notranslate\">check_password</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\">WSGIScriptalias</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\" role=\"note\">\n<p class=\"admonition-title\">Apache 2.2 a úsáid le fíordheimhniú</p>\n<p>Déan cinnte go bhfuil mod_auth_basic` agus <code class=\"docutils literal notranslate\">mod_authz_user</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> auth_basic_module modules/mod_auth_basic.so\n<span class=\"nb\">LoadModule</span> authz_user_module modules/mod_authz_user.so\n</code></pre></div>\n</aside>\n<p>Faoi dheireadh, cuir do script WSGI <code class=\"docutils literal notranslate\">mysite.wsgi</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\">check_password</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=\"nn\">os</span>\n\nos<span class=\"o\">.</span>environ<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=\"nn\">django.contrib.auth.handlers.modwsgi</span> <span class=\"kn\">import</span> check_password\n\n<span class=\"kn\">from</span> <span class=\"nn\">django.core.handlers.wsgi</span> <span class=\"kn\">import</span> WSGIHandler\n\napplication <span class=\"o\">=</span> WSGIHandler<span class=\"p\">()</span>\n</code></pre></div>\n<p>Beidh iarratais a thosaíonn le <code class=\"docutils literal notranslate\">/rúdaí/</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=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n\n<span class=\"nb\">WSGIProcessGroup</span> %{GLOBAL}\n<span class=\"nb\">WSGIApplicationGroup</span> %{GLOBAL}\n\n<span class=\"nt\">&lt;Location</span> <span class=\"s\">&quot;/secret&quot;</span><span class=\"nt\">&gt;</span>\n    <span class=\"nb\">AuthType</span> Basic\n    <span class=\"nb\">AuthName</span> <span class=\"s2\">&quot;Top Secret&quot;</span>\n    <span class=\"nb\">AuthBasicProvider</span> wsgi\n    <span class=\"nb\">WSGIAuthUserScript</span> <span class=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n    <span class=\"nb\">WSGIAuthGroupScript</span> <span class=\"sx\">/path/to/mysite.com/mysite/wsgi.py</span>\n    <span class=\"nb\">Require</span> <span class=\"k\">group</span> secret-agents\n    <span class=\"nb\">Require</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\">WSGIAuthGroupScript</code>, ní mór don script WSGI céanna <code class=\"docutils literal notranslate\">mysite.wsgi</code> an fheidhm <code class=\"docutils literal notranslate\">groups_for_user</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=\"nn\">django.contrib.auth.handlers.modwsgi</span> <span class=\"kn\">import</span> check_password<span class=\"p\">,</span> groups_for_user\n</code></pre></div>\n<p>Éilíonn iarratais ar <code class=\"docutils literal notranslate\">/rúna/</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/5.2/howto/"},{"docname":"howto/deployment/index","title":"Conas Django a imscaradh","url":"/ga/5.2/howto/deployment/"},{"docname":"howto/deployment/wsgi/index","title":"Conas a imscaradh le WSGI","url":"/ga/5.2/howto/deployment/wsgi/"}],"prev":{"docname":"howto/deployment/wsgi/modwsgi","title":"Conas Django a úsáid le Apache agus mod_wsgi","url":"/ga/5.2/howto/deployment/wsgi/modwsgi/"},"next":{"docname":"howto/deployment/asgi/index","title":"Conas a imscaradh le ASGI","url":"/ga/5.2/howto/deployment/asgi/"},"formats":{"html":"/ga/5.2/howto/deployment/wsgi/apache-auth/","markdown":"/ga/5.2/howto/deployment/wsgi/apache-auth.md","json":"/ga/5.2/howto/deployment/wsgi/apache-auth.json"},"source":"https://github.com/django/django/blob/stable/5.2.x/docs/howto/deployment/wsgi/apache-auth.txt","official":"https://docs.djangoproject.com/ga/5.2/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"]}