def post(request):
        """
            method called on POST request on this view

            :param django.http.HttpRequest request: The current request object
            :return: ``HttpResponse(u"yes\\n")`` if the POSTed tuple (username, password, service)
                if valid (i.e. (username, password) is valid dans username is allowed on service).
                ``HttpResponse(u"no\\n…")`` otherwise, with possibly an error message on the second
                line.
            :rtype: django.http.HttpResponse
        """
        username = request.POST.get('username')
        password = request.POST.get('password')
        service = request.POST.get('service')
        secret = request.POST.get('secret')

        if not settings.CAS_AUTH_SHARED_SECRET:
            return HttpResponse(
                "no\nplease set CAS_AUTH_SHARED_SECRET",
                content_type="text/plain; charset=utf-8"
            )
        if secret != settings.CAS_AUTH_SHARED_SECRET:
            return HttpResponse(u"no\n", content_type="text/plain; charset=utf-8")
        if not username or not password or not service:
            return HttpResponse(u"no\n", content_type="text/plain; charset=utf-8")
        form = forms.UserCredential(
            request.POST,
            initial={
                'service': service,
                'method': 'POST',
                'warn': False
            }
        )
        if form.is_valid():
            try:
                user = models.User.objects.get_or_create(
                    username=form.cleaned_data['username'],
                    session_key=request.session.session_key
                )[0]
                user.save()
                # is the service allowed
                service_pattern = ServicePattern.validate(service)
                # is the current user allowed on this service
                service_pattern.check_user(user)
                if not request.session.get("authenticated"):
                    user.delete()
                return HttpResponse(u"yes\n", content_type="text/plain; charset=utf-8")
            except (ServicePattern.DoesNotExist, models.ServicePatternException):
                return HttpResponse(u"no\n", content_type="text/plain; charset=utf-8")
        else:
            return HttpResponse(u"no\n", content_type="text/plain; charset=utf-8")
def post ( request ) : username = request . POST . get ( 'username' ) password = request . POST . get ( 'password' ) service = request . POST . get ( 'service' ) secret = request . POST . get ( 'secret' ) if not settings . CAS_AUTH_SHARED_SECRET : return HttpResponse ( "no\nplease set CAS_AUTH_SHARED_SECRET" , content_type = "text/plain; charset=utf-8" ) if secret != settings . CAS_AUTH_SHARED_SECRET : return HttpResponse ( u"no\n" , content_type = "text/plain; charset=utf-8" ) if not username or not password or not service : return HttpResponse ( u"no\n" , content_type = "text/plain; charset=utf-8" ) form = forms . UserCredential ( request . POST , initial = { 'service' : service , 'method' : 'POST' , 'warn' : False } ) if form . is_valid ( ) : try : user = models . User . objects . get_or_create ( username = form . cleaned_data [ 'username' ] , session_key = request . session . session_key ) [ 0 ] user . save ( ) service_pattern = ServicePattern . validate ( service ) service_pattern . check_user ( user ) if not request . session . get ( "authenticated" ) : user . delete ( ) return HttpResponse ( u"yes\n" , content_type = "text/plain; charset=utf-8" ) except ( ServicePattern . DoesNotExist , models . ServicePatternException ) : return HttpResponse ( u"no\n" , content_type = "text/plain; charset=utf-8" ) else : return HttpResponse ( u"no\n" , content_type = "text/plain; charset=utf-8" )
method called on POST request on this view

            :param django.http.HttpRequest request: The current request object
            :return: ``HttpResponse(u"yes\\n")`` if the POSTed tuple (username, password, service)
                if valid (i.e. (username, password) is valid dans username is allowed on service).
                ``HttpResponse(u"no\\n…")`` otherwise, with possibly an error message on the second
                line.
            :rtype: django.http.HttpResponse