<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                企業??AI智能體構建引擎,智能編排和調試,一鍵部署,支持知識庫和私有化部署方案 廣告
                [TOC] # 1. 關閉CSRF保護演示 **1. 關閉CSRF保護** ```java @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { //關閉csrf http.csrf().disable(); } } ``` **2. controller層** ```java /** * post方式訪問 */ @PostMapping("/v2/csrf/form") @ResponseBody public Account getAccount(Account account) { return account; } ``` **3. 表單以POST方式提交** ```html <form action="/v2/csrf/form" method="post"> id:<input type="text" name="id"/><br/> username:<input type="text" name="username"/><br/> password:<input type="text" name="password"/><br/> <input type="submit"/> </form> ``` **4. 結果** 可以正常提交。 <br/> # 2. 啟用CSRF保護演示 **1. 啟用CSRF保護** ```java @Configuration public class SecurityConfig extends WebSecurityConfigurerAdapter { @Override protected void configure(HttpSecurity http) throws Exception { //不調用代碼http.csrf().disable()就是開啟csrf保護了 //http.csrf().disable(); } } ``` **2. controller層** ```java /** * post方式訪問。 * Spring Security CSRF 只針對 PATCH,POST,PUT 和 DELETE 方法進行防護,GET方法不防護。 */ @PostMapping("/v2/csrf/form") @ResponseBody public Account getAccount(Account account) { return account; } ``` **3. 表單以POST方式提交** ```html <form action="/v2/csrf/form" method="post"> id:<input type="text" name="id"/><br/> username:<input type="text" name="username"/><br/> password:<input type="text" name="password"/><br/> <input type="submit"/> </form> ``` **4. 結果:表單不能提交,重定向到403頁面** ``` Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Fri Jun 10 20:21:37 CST 2022 There was an unexpected error (type=Forbidden, status=403). Forbidden ``` **5. 在表單內添加csrf的隱藏域便可提交了** ```html <form action="/v2/csrf/form" method="post"> id:<input type="text" name="id"/><br/> username:<input type="text" name="username"/><br/> password:<input type="text" name="password"/><br/> <input type="hidden" th:if="${_csrf}!=null" th:value="${_csrf.token}" th:name="${_csrf.parameterName}"/> <input type="submit"/> </form> ``` <br/>
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看