gpt4 book ai didi

javascript - chalice : call to public action redirects to login page

转载 作者:行者123 更新时间:2023-11-30 05:44:17 24 4
gpt4 key购买 nike

我正在从 php 到 grails 应用程序进行跨域 ajax 调用。

我的 php 脚本:

$uid=$_GET['uid'];
function getData($uid)

{
$dataUrl='http://localhost:8080/profile/user/teacher?id='.$uid;
$json=file_get_contents($dataUrl);
print_r($json);

}
getData($uid);

调用此 php 脚本的 Javascript 是

$.getJSON('userdata.php?uid'+1,function(data){
console.log(data);
});

在这里,当我执行 getJSON 调用时,它会转到我的应用程序的登录页面,即使我没有检查是否已登录该特定方法。即它是一种公共(public)方法,我无需登录即可访问。

我正在使用 springsecurity 插件进行身份验证管理。

最佳答案

这可能是因为 spring 安全性(可能是您的操作或 Controller 具有安全注释,或者可能是操作通过配置中的 url 映射是安全的)。

可以绕过

如果使用注解

@Secured('IS_AUTHENTICATED_ANONYMOUSLY')
def teacher() {
....
}

如果在配置中使用 url 映射

grails.plugins.springsecurity.interceptUrlMap = [
...
'/user/teacher/**': ['IS_AUTHENTICATED_ANONYMOUSLY'],
...
]

关于javascript - chalice : call to public action redirects to login page,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18826411/

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