【发布时间】:2020-12-24 05:46:41
【问题描述】:
所以我尝试在我的 Spring Boot 应用程序上使用配置 iframe。但是,我正在努力将 X-Frame-Options 设置为 ALLOW-From。这是我的 html 和 spring 安全文件的内容。
HTML IFrame:
<div class="gridItem8">
<iframe src="https://www.youtube.com/watch?v=HV2LVEPrKGs&feature=emb_title" title="Halo Video"></iframe>
安全配置:
protected void configure(HttpSecurity http) throws Exception {
http
.authorizeRequests()
.antMatchers().authenticated()
.antMatchers( "/", "/about", "/signup", "/signUpForm",
"/signUpFormError", "/login", "/logOut", "/ForgotPasswordPage", "/Forgot_Password",
"/SignUp", "/registrationComplete").permitAll()
.antMatchers("/LoggedInUser/**").hasAnyAuthority("ADMIN", "USER", "MODERATOR")
.anyRequest().authenticated().and().csrf().disable().formLogin()
.loginPage("/login").failureUrl("/login?error=true")
.defaultSuccessUrl("/LoggedInUser/success")
.usernameParameter("email")
.passwordParameter("password")
.and().logout()
.logoutRequestMatcher(new AntPathRequestMatcher("/logOut"))
.logoutSuccessUrl("/")
.and()
.headers()
.frameOptions()
.disable()
.addHeaderWriter(new StaticHeadersWriter("X-FRAME-OPTIONS",
"ALLOW-FROM https://www.youtube.com/watch?v=HV2LVEPrKGs&feature=emb_title"));
任何帮助将不胜感激。谢谢!
【问题讨论】:
标签: java spring spring-boot iframe x-frame-options