Java 什么';s带有spring安全性的表单地址
我有一个关于使用spring安全性的问题。我有一个node.js http服务器(localhost:8000)和一个spring引导项目(localhost:8090)。我在spring引导项目中使用spring安全性。这是我的配置Java 什么';s带有spring安全性的表单地址,java,spring,spring-security,Java,Spring,Spring Security,我有一个关于使用spring安全性的问题。我有一个node.js http服务器(localhost:8000)和一个spring引导项目(localhost:8090)。我在spring引导项目中使用spring安全性。这是我的配置 @Configuration @EnableWebSecurity public class SecurityConfig extends WebSecurityConfigurerAdapter { @Autowired HunterUserRepositor
@Configuration
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter {
@Autowired
HunterUserRepository repository;
@Override
protected void configure(AuthenticationManagerBuilder auth) throws Exception{
auth.userDetailsService(new HunterUserSecurityServices(repository));
}
@Override
protected void configure(HttpSecurity http) throws Exception{
http
.authorizeRequests().anyRequest().permitAll()
.and()
.authorizeRequests()
.antMatchers("/api/private/**").authenticated()
.and().formLogin().loginPage("/login").permitAll();
http.csrf().disable();
}
}
这是http服务器中的my login.html:
<form class="form-signin" action="http://localhost:8090/login" method="POST">
<h2>请登录<div class="pull-right"><small><a href="#">注册</a></small></div></h2>
<label for="username" class="sr-only">用户名</label>
<input name="username" type="text" id="username" class="form-control" placeholder="用户名" required autofocus style="margin-bottom: 10px">
<label for="inputPassword" class="sr-only">密码</label>
<input name="password" type="password" id="inputPassword" class="form-control" placeholder="密码" required style="margin-bottom: 10px">
<button class="btn btn-lg btn-primary btn-block" type="submit" name="submit" value="Login">登录</button>
</form>
我想这可能是spring安全性的问题,因为当我在spring boot中添加控制器时,如下所示:
@RestController
//@CrossOrigin
public class LoginController {
@RequestMapping("/login")
String login(){
return "login";
}
}
当我访问login.html提交时,我得到了字符串“login”
我不知道为什么,我能找到的关于spring安全性的所有消息都使用jsp或thylef。也许我缺少一些关于春季安全的东西
有人知道我怎么做吗?thx很多。我刚从
http://stackoverflow.com/questions/21696592/disable-spring-security-for-options-http-method
bylucs
,因此我忽略了http选项,并将其设置为。
希望这能对您有所帮助。不,我把所有页面都放在node.js http服务器上,我不知道如何描述,这是所谓的前端和后端。
@RestController
//@CrossOrigin
public class LoginController {
@RequestMapping("/login")
String login(){
return "login";
}
}