(func, *args, **kwargs)
Decorator for authenticating a form

    This decorator uses an authorization token stored in the client's
    session for prevention of certain Cross-site request forgery (CSRF)
    attacks (See
    http://en.wikipedia.org/wiki/Cross-site_request_forgery for more
    information).

    For use with the ``webhelpers.html.secure_form`` helper functions.
Decorator for authenticating a form
Decorator for authenticating a form
def authenticate_form(func, *args, **kwargs):
    """Decorator for authenticating a form

    This decorator uses an authorization token stored in the client's
    session for prevention of certain Cross-site request forgery (CSRF)
    attacks (See
    http://en.wikipedia.org/wiki/Cross-site_request_forgery for more
    information).

    For use with the ``webhelpers.html.secure_form`` helper functions.

    """
    request = get_pylons(args).request
    if authenticated_form(request.params):
        try:
            del request.POST[secure_form.token_key]
        except KeyError:
            del request.GET[secure_form.token_key]
        return func(*args, **kwargs)
    else:
        log.warn('Cross-site request forgery detected, request denied: %r '
                 'REMOTE_ADDR: %s' % (request, request.remote_addr))
        abort(403, detail=csrf_detected_message)
def authenticate_form ( func , * args , * * kwargs ) : request = get_pylons ( args ) . request if authenticated_form ( request . params ) : try : del request . POST [ secure_form . token_key ] except KeyError : del request . GET [ secure_form . token_key ] return func ( * args , * * kwargs ) else : log . warn ( 'Cross-site request forgery detected, request denied: %r ' 'REMOTE_ADDR: %s' % ( request , request . remote_addr ) ) abort ( 403 , detail = csrf_detected_message )