gpt4 book ai didi

javascript - Azure 单点登录发布请求时出现 403 禁止错误

转载 作者:行者123 更新时间:2023-12-03 07:08:33 25 4
gpt4 key购买 nike

我正在开发 jsp-springboot 应用程序,我已经使用 azure 实现了 sso,并且它按预期工作。我已经配置了

azure.activedirectory.tenant-id

azure.activedirectory.client-id

azure.activedirectory.client-secret

我还添加了重定向网址在 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...");

}​​​​​
}​​​​​);

我不知道为什么 post 调用不起作用

最佳答案

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

CSRF protection is enabled by default in the Java configuration. We can still disable it if we need to:

@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

关于javascript - Azure 单点登录发布请求时出现 403 禁止错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/70941476/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com