Skip to content

Commit fc4161a

Browse files
committed
Add API docs for reactive security
1 parent cd5eba4 commit fc4161a

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

project-management/src/main/java/life/qbic/projectmanagement/application/authorization/ReactiveSecurityContextUtils.java

+22-2
Original file line numberDiff line numberDiff line change
@@ -46,15 +46,35 @@ public static <T> Mono<T> applySecurityContext(Mono<T> original) {
4646
});
4747
}
4848

49+
/**
50+
* Same as {@link #applySecurityContext(Mono)} but applies to {@link Flux}.
51+
*
52+
* @param original the original reactive stream
53+
* @param <T> the type of the flux
54+
* @return the reactive stream for which the security context has been set explicitly
55+
* @since 1.10.0
56+
*/
4957
public static <T> Flux<T> applySecurityContextMany(Flux<T> original) {
5058
return ReactiveSecurityContextHolder.getContext().flatMapMany(securityContext -> {
5159
SecurityContextHolder.setContext(securityContext);
5260
return original;
5361
});
5462
}
5563

56-
public static <T> Flux<T> writeSecurityContextMany(Flux<T> original, SecurityContext securityContext) {
57-
return original.contextWrite(ReactiveSecurityContextHolder.withSecurityContext(Mono.just(securityContext)));
64+
/**
65+
* Same as {@link #writeSecurityContext(Mono, SecurityContext)} but applies to {@link Flux}.
66+
*
67+
* @param original the original reactive stream
68+
* @param securityContext the security context to write into the context of the flux
69+
* @param <T> the type of the flux
70+
* @return the reactive stream for which the {@link ReactiveSecurityContextHolder} has been
71+
* configured with the provided {@link SecurityContext}.
72+
* @since 1.10.0
73+
*/
74+
public static <T> Flux<T> writeSecurityContextMany(Flux<T> original,
75+
SecurityContext securityContext) {
76+
return original.contextWrite(
77+
ReactiveSecurityContextHolder.withSecurityContext(Mono.just(securityContext)));
5878
}
5979

6080
}

0 commit comments

Comments
 (0)