Deal of The Day! Hurry Up, Grab the Special Discount - Save 25% - Ends In 00:00:00 Coupon code: SAVE25
Welcome to Pass4Success

- Free Preparation Discussions

Salesforce Comm-Dev-101 Exam - Topic 2 Question 8 Discussion

Posted by Merilyn on Oct 26, 2026 at 03:10 AM

To ensure SFRA best practices and protect against request forgery, the developer introduced CSRF token generation in the customer address form.

value="${dw.web.CSRFProtection.generateToken()}">

...

....

To implement CSRF protection when the form is submitted, the developer needs to introduce the CSRF validation using one or both of these methods as applicable:

validateRequest

validateAjaxRequest

Where in the code does the developer need to add this CSRF validation check?

Suggested Answer: A

CSRF validation must occurwhen the state-changing request is submitted, before protected business logic executes. In SFRA this is implemented as middleware in the controller's POST route, using the appropriate CSRF middleware---validateRequestfor standard submissions orvalidateAjaxRequestfor AJAX-based requests.

Salesforce's SFRA Forms documentation specifically states that CSRF protection is supplied as middleware and demonstrates CSRF checks as middleware steps. The underlyingdw.web.CSRFProtection.validateRequest()API verifies that the request contains the system-generated token and that the token has not expired.

Generating the token in the template only establishes the client-side value; it does not provide security unless the receiving POST endpoint validates it. Placing validation only in the form-display route would validate the wrong request. Performing validation in a persistence model is also too late because request security should be enforced before mutation logic is invoked.

Study Guide reference:Application Development --- CSRF protection, SFRA middleware, POST routes,validateRequest,validateAjaxRequest, and secure form processing.

===============


Get Premium Comm-Dev-101 Questions as Interactive Web-Based Practice Test or PDF Real Exam Format Detailed Explanations Instant Access Get Your Practice Test
0 comments · newest first

Currently there are no comments in this discussion, be the first to comment!

0/2000 characters

Save Cancel