mirror of
https://github.com/spring-projects/spring-security.git
synced 2025-07-14 22:33:31 +00:00
WebSessionServerCsrfTokenRepository session fixation protection
Issue: gh-4842
This commit is contained in:
parent
75a7c5268a
commit
b19e14330f
@ -61,6 +61,7 @@ public class WebSessionServerCsrfTokenRepository
|
|||||||
}
|
}
|
||||||
return exchange.getSession()
|
return exchange.getSession()
|
||||||
.doOnSuccess(session -> putToken(session.getAttributes(), token))
|
.doOnSuccess(session -> putToken(session.getAttributes(), token))
|
||||||
|
.flatMap(session -> session.changeSessionId())
|
||||||
.flatMap(r -> Mono.justOrEmpty(token));
|
.flatMap(r -> Mono.justOrEmpty(token));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -102,4 +102,12 @@ public class WebSessionServerCsrfTokenRepositoryTests {
|
|||||||
load = this.repository.loadToken(this.exchange).block();
|
load = this.repository.loadToken(this.exchange).block();
|
||||||
assertThat(load).isNull();
|
assertThat(load).isNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void saveTokenChangeSessionId() {
|
||||||
|
String originalSessionId = this.exchange.getSession().block().getId();
|
||||||
|
this.repository.saveToken(this.exchange, null).block();
|
||||||
|
WebSession session = this.exchange.getSession().block();
|
||||||
|
assertThat(session.getId()).isNotEqualTo(originalSessionId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user