use of org.springframework.security.web.server.csrf.CsrfToken in project spring-security by spring-projects.
the class LoginPageGeneratingWebFilter method createBuffer.
private Mono<DataBuffer> createBuffer(ServerWebExchange exchange) {
Mono<CsrfToken> token = exchange.getAttributeOrDefault(CsrfToken.class.getName(), Mono.empty());
return token.map(LoginPageGeneratingWebFilter::csrfToken).defaultIfEmpty("").map((csrfTokenHtmlInput) -> {
byte[] bytes = createPage(exchange, csrfTokenHtmlInput);
DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory();
return bufferFactory.wrap(bytes);
});
}
use of org.springframework.security.web.server.csrf.CsrfToken in project spring-security by spring-projects.
the class LogoutPageGeneratingWebFilter method createBuffer.
private Mono<DataBuffer> createBuffer(ServerWebExchange exchange) {
Mono<CsrfToken> token = exchange.getAttributeOrDefault(CsrfToken.class.getName(), Mono.empty());
return token.map(LogoutPageGeneratingWebFilter::csrfToken).defaultIfEmpty("").map((csrfTokenHtmlInput) -> {
byte[] bytes = createPage(csrfTokenHtmlInput);
DataBufferFactory bufferFactory = exchange.getResponse().bufferFactory();
return bufferFactory.wrap(bytes);
});
}
use of org.springframework.security.web.server.csrf.CsrfToken in project spring-security by spring-projects.
the class CsrfRequestDataValueProcessorTests method createGetExtraHiddenFieldsHasCsrfToken.
@Test
public void createGetExtraHiddenFieldsHasCsrfToken() {
CsrfToken token = new DefaultCsrfToken("1", "a", "b");
this.exchange.getAttributes().put(CsrfRequestDataValueProcessor.DEFAULT_CSRF_ATTR_NAME, token);
Map<String, String> expected = new HashMap<>();
expected.put(token.getParameterName(), token.getToken());
CsrfRequestDataValueProcessor processor = new CsrfRequestDataValueProcessor();
assertThat(this.processor.getExtraHiddenFields(this.exchange)).isEqualTo(expected);
}
Aggregations