我有这个SpringBoot安全配置:
@Override
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers(HttpMethod.PUT, "/api/**").permitAll()
.antMatchers(publicMatchers()).permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").defaultSuccessUrl("/book/list")
.failureUrl("/login?error").permitAll()
.and()
.logout().permitAll();
}
private String[] publicMatchers() {
/** Public URLs. */
final String[] PUBLIC_MATCHERS = {
"/webjars/**",
serverContextPath + "/css/**",
serverContextPath + "/js/**",
serverContextPath + "/fonts/**",
serverContextPath + "/images/**",
"/api/**",
serverContextPath ,
"/",
"/error/**/*",
"/console/**",
ForgotMyPasswordController.FORGOT_PASSWORD_URL_MAPPING,
ForgotMyPasswordController.CHANGE_PASSWORD_PATH,
SignupController.SIGNUP_URL_MAPPING
};
return PUBLIC_MATCHERS;
}
期望此URL http://localhost:5678/pradera/api/users/fcm(使用PUT方法)将是公开的,但是当我在Postman上对其进行测试时,II将我重定向到登录页面
在publicMatchers()方法上,我也有"/api/**",
,它似乎适用于调用http://localhost:5678/pradera/api/deviceevent/list(GET)
答案 0 :(得分:1)
添加此内容:def any_function(item):
print(item)
def calling_function():
list1 = ['38','39', '40']
for item in list1:
any_function(item)