Hi every one,
My ldap login is not protect my site. One can access just typing a url. 
What is wrong?
These site is just a set of html templates.

-----------------------
settings.py
-----------------------
AUTH_LDAP_SERVER_URI = "ldap://ldap.city.company";
AUTH_LDAP_BIND_DN = "uid=host,ou=wan,ou=corp,dc=company,dc=gov,dc=br"
AUTH_LDAP_BIND_PASSWORD = 'password'
AUTH_LDAP_USER_SEARCH = LDAPSearch(
    'dc=company,dc=gov,dc=br',
    ldap.SCOPE_SUBTREE,
    '(uid=%(user)s)',
)
AUTH_LDAP_USER_ATTR_MAP = {
"full_name": "cn",
"username": "uid",
"mail": "mail",
}

# This is the default, but I like to be explicit.
AUTH_LDAP_ALWAYS_UPDATE_USER = True

# Cache distinguised names and group memberships for an hour to minimize
# LDAP traffic.
AUTH_LDAP_CACHE_TIMEOUT = 3600

# Keep ModelBackend around for per-user permissions and maybe a local
# superuser.
AUTHENTICATION_BACKENDS = (
    'django_auth_ldap.backend.LDAPBackend',
    'django.contrib.auth.backends.ModelBackend',
)

-----------------------
view.py
-----------------------
from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import never_cache
from django.utils.decorators import method_decorator
from django.views.generic import TemplateView

decorators = [never_cache, login_required]

@method_decorator(decorators, name='dispatch')
class ProtectedView(TemplateView):
    template_name = 'Racks.html'

@method_decorator(never_cache, name='dispatch')
@method_decorator(login_required, name='dispatch')
class ProtectedView(TemplateView):
    template_name = 'Racks.html'

-----------------------
urls.py
-----------------------
from django.urls import path
from django.contrib import admin
from django.contrib.auth.views import LoginView 
from . import views
from django.conf.urls.static import static
from django.conf import settings

urlpatterns = [
    path(r'', LoginView.as_view(template_name='login.html'), name='redes'),
    path(r'redes/', LoginView.as_view(template_name='login.html'), 
name='redes'),
    path(r'Racks/', 
views.ProtectedView.as_view(template_name='Racks.html'), name='racks'),
...
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b7c68fcf-c9e2-4d95-975b-a12076afadab%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to