0
私はZuulの後ろにOauth2サーバーを実行しています。 Zuulはユーザーをログインページに転送します。 ZuulもHttpSecurity以下を定義します。FreemarkerテンプレートのSpring CSRFトークンヌル
@Override
public void configure(HttpSecurity http) throws Exception {
...
.and().csrf().csrfTokenRepository(CookieCsrfTokenRepository.withHttpOnlyFalse());
}
のOAuth2サーバー上のログインFreemarkerのテンプレートは、このようなCSRFトークン解析します。ここまで
<from>
...
<input type="hidden" id="csrf_token" name="${_csrf.parameterName}" value="${_csrf.token}"/>
</form>
を、すべてが正常に動作します。
次WebMvcConfigurerAdapter構成とともに<a href="/uaa/reset"><@spring.message "login.forgot"/></a>
:いいえ、私はパスワードへのリンクFreemarkerのテンプレートをリセットを含め、私はリセットビューに移動すると
@Configuration
public class OAuthWebFormConfiguration extends WebMvcConfigurerAdapter {
@Override
public void addViewControllers(ViewControllerRegistry registry) {
registry.addViewController("/login").setViewName("login");
registry.addViewController("/reset").setViewName("reset");
}
私は次のエラーを取得する:
: Servlet.service() for servlet [dispatcherServlet] in context with path
[/uaa] threw exception [Request processing failed; nested exception is
freemarker.core.InvalidReferenceException: The following has evaluated to
null or missing:
==> _csrf [in template "reset.ftl" at line 21, column 64]
Tip: If the failing expression is known to legally refer to something
that's sometimes null or missing, either specify a default value like
myOptionalVar!myDefault, or use <#if myOptionalVar??>when-
present<#else>when-missing</#if>. (These only cover the last step of the
expression; to cover the whole expression, use parenthesis:
(myOptionalVar.foo)!myDefault, (myOptionalVar.foo)??
FTL stack trace ("~" means nesting-related):
- Failed at: ${_csrf.parameterName} [in template "reset.ftl" at line 21,
column 62]
----] with root cause
freemarker.core.InvalidReferenceException: The following has evaluated to
null or missing:
==> _csrf [in template "reset.ftl" at line 21, column 64]
Tip: If the failing expression is known to legally refer to something that's
sometimes null or missing, either specify a default value like
myOptionalVar!myDefault, or use <#if myOptionalVar??>when-
present<#else>when-
missing</#if>. (These only cover the last step of the expression; to cover
the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault,
(myOptionalVar.foo)??
FTL stack trace ("~" means nesting-related):
- Failed at: ${_csrf.parameterName} [in template "reset.ftl" at line 21,
column 62]
助けが必要ですか?