2017-03-07 8 views
-1

私は春のセキュリティを使用することについて質問があります。私はnode.js httpサーバー(localhost:8000)と春のブートプロジェクト(localhost:8090)を持っています。ブートproject.Hereは私の設定春のセキュリティとフォームのアドレス

@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サーバーの私の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> 

iが http://localhost:8000/login.htmlを訪問し、私はalreadlyモンゴに持っていた私のユーザー名とパスワードを入力し、私は

Whitelabel Error Page 

This application has no explicit mapping for /error, so you are seeing this as a fallback. 

Tue Mar 07 20:30:15 CST 2017 
There was an unexpected error (type=Not Found, status=404). 
No message available 

私はこのような春ブーツにコントローラを追加するときので、それは、春のセキュリティの問題である可能性を推測:

@RestController 
//@CrossOrigin 
public class LoginController { 
    @RequestMapping("/login") 
    String login(){ 
     return "login"; 
    } 
} 

と私はlogin.htmlとをvisied際、提出し、私は「文字列を得ましたログイン"。

私はなぜ春のセキュリティについては、jspやthylefを使用して見つけることができるすべてのメッセージを知っていない。だから多分私は春のセキュリティについて何か不足しています。

私はどのようにそれを作ることができるか知っていますか?ありがとう。

+0

いいえ、私はnode.js http-serverにすべてのページを置いています。私は、どのようにdescするのか分かりません。これはいわゆるフロントエンドとバックエンドです。 – Dade

答えて

-1

ヘイ私はちょうどhttp://stackoverflow.com/questions/21696592/disable-spring-security-for-options-http-methodからLuc Sで答えを得ました。だから、私はhttpオプションを無視して、それを作っています。 これがあなたを助けてくれることを願っています。

関連する問題