Expose Principal in ServerRequest
This commit exposes the Principal in ServerRequest. Issue: SPR-15552
This commit is contained in:
@@ -19,6 +19,7 @@ package org.springframework.web.reactive.function.server;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Principal;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
@@ -157,6 +158,11 @@ class DefaultServerRequest implements ServerRequest {
|
||||
return this.exchange.getSession();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<? extends Principal> principal() {
|
||||
return this.exchange.getPrincipal();
|
||||
}
|
||||
|
||||
private ServerHttpRequest request() {
|
||||
return this.exchange.getRequest();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package org.springframework.web.reactive.function.server;
|
||||
|
||||
import java.net.URI;
|
||||
import java.security.Principal;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
@@ -543,6 +544,11 @@ public abstract class RequestPredicates {
|
||||
return this.request.session();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<? extends Principal> principal() {
|
||||
return this.request.principal();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return method() + " " + path();
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.reactive.function.server;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Principal;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -168,6 +169,11 @@ public interface ServerRequest {
|
||||
*/
|
||||
Mono<WebSession> session();
|
||||
|
||||
/**
|
||||
* Return the authenticated user for the request, if any.
|
||||
*/
|
||||
Mono<? extends Principal> principal();
|
||||
|
||||
|
||||
/**
|
||||
* Represents the headers of the HTTP request.
|
||||
|
||||
@@ -19,6 +19,7 @@ package org.springframework.web.reactive.function.server.support;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.net.URI;
|
||||
import java.nio.charset.Charset;
|
||||
import java.security.Principal;
|
||||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
@@ -144,6 +145,10 @@ public class ServerRequestWrapper implements ServerRequest {
|
||||
return this.delegate.session();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mono<? extends Principal> principal() {
|
||||
return this.delegate.principal();
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of the {@code Headers} interface that can be subclassed
|
||||
|
||||
Reference in New Issue
Block a user