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

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

Introduction

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

Prototype

HttpSessionCsrfTokenRepository

Source Link

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: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:net.prasenjit.auth.config.SecurityConfig.java

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

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
 *//*from   ww  w.  j a  va  2 s.  com*/
private CsrfTokenRepository csrfTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName("X-XSRF-TOKEN");
    return repository;
}

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

/**
 * https://spring.io/guides/tutorials/spring-security-and-angular-js/
 * //from  w  w  w . j  a  v  a  2 s .co  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: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//from www.  ja  va 2  s  . c o m
 */
private CsrfTokenRepository getCSRFTokenRepository() {
    HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName(CSRF_ANGULAR_HEADER_NAME);
    return repository;
}

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

/**
 * Create a CSRF token repository.//from  w  w w  .j a v  a2s  .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;
}

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

/**
 * define csrf header entry./*from   w ww .  j a v a  2  s .  com*/
 *
 * @return csrf header entry
 */
@Bean
public CsrfTokenRepository csrfTokenRepository() {
    final HttpSessionCsrfTokenRepository repository = new HttpSessionCsrfTokenRepository();
    repository.setHeaderName(ResourcePaths.XSRF_HEADER);
    return repository;
}