我對這些框架(Vaadin:7.6.1,Spring Security:4.0.3)感興趣,我想問問自己如何構建Vaadin應用程序的授權請求。用於Vaadin的Spring Security的Java配置
我擡頭一看,其中是這樣寫的幾個例子:
@EnableWebSecurity
public class SecurityConfig extends WebSecurityConfigurerAdapter
{
[...]
@Override
protected void configure(HttpSecurity http) throws Exception
{
http
.authorizeRequests()
.antMatchers("/login**").permitAll()
.antMatchers("/UIDL/**").permitAll()
.antMatchers("/HEARTBEAT/**").authenticated()
.antMatchers("/VAADIN/**").permitAll()
.antMatchers("/resources/**").permitAll()
.anyRequest().authenticated()
.and()
.formLogin().loginPage("/login").permitAll()
.and()
.logout().permitAll()
.and()
.csrf().disable();
}
}
因爲我要設計我用的是Thymeleaf engine登錄頁面。所以我使用這個控制器類:
如果我想阻止我的應用程序的每個請求,如果用戶沒有登錄我應該定義@Controller
public class LoginController
{
@RequestMapping("/login")
String login(Model model)
{
return "login";
}
}
其中.antMatchers()?我知道我必須爲登錄頁面定義antMatchers(「/ resources/**」)。permitAll()以獲取css和圖像。但是這些模式像「/ UIDL/**」是什麼,我需要它們什麼?
謝謝您的回覆。 1.爲什麼使用** configure(WebSecurity web)**方法忽略資源而不是** configure(HttpSecurity http)**允許訪問?有重大差異嗎? 2.爲什麼你忽略「/ VAADIN/**」路徑? 3.我可以想象「/ *」和「/ **」的含義,但「UIDL」和「HEARTBEAT」究竟意味着什麼?他們爲什麼被允許? – shinchillahh