Example usage for org.springframework.security.web.csrf HttpSessionCsrfTokenRepository setHeaderName

List of usage examples for org.springframework.security.web.csrf HttpSessionCsrfTokenRepository setHeaderName

Introduction

In this page you can find the example usage for org.springframework.security.web.csrf HttpSessionCsrfTokenRepository setHeaderName.

Prototype

public void setHeaderName(String headerName) 

Source Link

Document

Sets the header name that the CsrfToken is expected to appear on and the header that the response will contain the CsrfToken .

Usage

From source file:br.com.edo.atmlist.config.SecurityConfig.java

private CsrfTokenRepository csrfTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName("X-XSRF-TOKEN");
    return repository;
}

From source file:com.arya.latihan.config.SecurityConfiguration.java

/**
 * Method untuk mengubah format CSRF TOKEN menjadi format yang dikenali oleh AngularJS.
 * Format default adalah X-CSRF-TOKEN diubah menjadi X-XSRF-TOKEN
 * @return HttpSessionCsrfTokenRepository
 *///w w w.j av  a2s . c  o  m
private CsrfTokenRepository csrfTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName("X-XSRF-TOKEN");
    return repository;
}

From source file:net.prasenjit.auth.config.SecurityConfig.java

private HttpSessionCsrfTokenRepository csrfTokenRepository() {
    HttpSessionCsrfTokenRepository tokenRepository = new HttpSessionCsrfTokenRepository();
    tokenRepository.setHeaderName("X-XSRF-TOKEN");
    return tokenRepository;
}

From source file:org.zaizi.sensefy.auth.LoginConfig.java

private CsrfTokenRepository csrfTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName("X-XSRF-TOKEN");
    return repository;

}

From source file:org.moserp.infrastructure.gateway.config.OAuthConfiguration.java

/**
 * Angular sends the CSRF token in a custom header named "X-XSRF-TOKEN"
 * rather than the default "X-CSRF-TOKEN" that Spring security expects.
 * Hence we are now telling Spring security to expect the token in the
 * "X-XSRF-TOKEN" header.<br><br>
 *
 * This customization is added to the <code>csrf()</code> filter.
 *
 * @return//  w  ww . j  ava 2  s .c om
 */
private CsrfTokenRepository getCSRFTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName(CSRF_ANGULAR_HEADER_NAME);
    return repository;
}

From source file:org.jimsey.projects.turbine.condenser.security.SecuritySetup.java

/**
 * https://spring.io/guides/tutorials/spring-security-and-angular-js/
 * /*from   ww  w  .  j  a v  a2 s  .c  o m*/
 * "The other thing we have to do on the server is tell Spring Security to
 * expect the CSRF token in the format that Angular wants to send it back
 * (a header called "X-XRSF-TOKEN" instead of the default "X-CSRF-TOKEN").
 * We do this by customizing the CSRF filter:"
 * 
 * @return
 */
private CsrfTokenRepository newCsrfTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName("X-XSRF-TOKEN");
    return repository;
}

From source file:io.interface21.SecurityConfiguration.java

private CsrfTokenRepository csrfTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    // Angular is sends CSRF tokens back to the server as header attribute named 'X-XSRF-TOKEN'
    repository.setHeaderName("X-XSRF-TOKEN");
    return repository;
}

From source file:de.knightsoftnet.validationexample.server.spring.WebSecurityConfig.java

/**
 * define csrf header entry./*w w w .ja  v  a  2s  .c  o m*/
 *
 * @return csrf header entry
 */
@Bean
public CsrfTokenRepository csrfTokenRepository() {
    final HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName(ResourcePaths.XSRF_HEADER);
    return repository;
}

From source file:uk.co.caprica.bootlace.security.SecurityConfiguration.java

/**
 * Create a CSRF token repository./* w  ww .j a v  a2  s .  c o  m*/
 * <p>
 * Use the standard CSRF token repository, but change the header name to that used by
 * AngularJS.
 *
 * @return CSRF token repository
 */
private CsrfTokenRepository csrfTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName(ANGULARJS_CSRF_TOKEN_HEADER);
    return repository;
}