簡體   English   中英

Azure 單點登錄發布請求給出 403 禁止錯誤

[英]Azure Single Sign on post request giving 403 forbidden error

我正在開發 jsp-springboot 應用程序,我已經使用 azure 實現了 sso,它按預期工作。 我已經配置

azure.activedirectory.tenant-id

azure.activedirectory.client-id

azure.activedirectory.client-secret

此外,我還添加了重定向 url 在 application.properties 中,除了這些更改之外,我沒有添加任何配置類,我也能夠成功登錄 ajax GET調用正在返回 200 響應代碼,但對於POST調用給出403禁止錯誤

獲取通話樣本

$.ajax({​​​​​
  type: 'GET',
  url: "/getvalue/"+productId,
  contentType: "text/plain",
  dataType: 'json',
   
  success: function (data) {​​​​​
     console.log("Success");
  }​​​​​,
  error: function (e) {​​​​​
    console.log("There was an error with your request...");
   
  }​​​​​
}​​​​​);

和郵局電話

  $.ajax({​​​​​
      type: 'POST',
      url: "/saveValue",
      data:JSON.stringify(valueObj),
      contentType: "application/json",
      success: function (data) {​​​​​
      console.log("success: ");
      }​​​​​,
      error: function (e) {​​​​​
        console.log("There was an error with your request...");
       
      }​​​​​
    }​​​​​);

我不知道為什么郵政電話不起作用

GET 上的 200 和 POST 上的 403 告訴我您仍然啟用了 CSRF。

CSRF 保護在 Java 配置中默認啟用。 如果需要,我們仍然可以禁用它:

@Override
protected void configure(HttpSecurity http) throws Exception {
    http
      .csrf().disable();
}

參考: https://www.baeldung.com/spring-security-csrf#1-java-configuration

我不建議禁用它。 您可以查看https://docs.spring.io/spring-security/reference/5.6.0-RC1/reactive/exploits/csrf.html#webflux-csrf-configure-custom-repository

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM