-
Notifications
You must be signed in to change notification settings - Fork 2.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add proper identity propagation to WebSockets
Fixes #16602
- Loading branch information
1 parent
db2f6b5
commit 6f265d6
Showing
24 changed files
with
292 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../AnnotatedWebsocketEndpointBuildItem.java → .../AnnotatedWebsocketEndpointBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...nt/ServerWebSocketContainerBuildItem.java → ...nt/ServerWebSocketContainerBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
4 changes: 2 additions & 2 deletions
4
...erWebSocketContainerFactoryBuildItem.java → ...erWebSocketContainerFactoryBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ent/WebSocketDeploymentInfoBuildItem.java → ...ent/WebSocketDeploymentInfoBuildItem.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ts/client/deployment/WebsocketConfig.java → ...ts/client/deployment/WebsocketConfig.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
.../websockets/test/TestWebSocketClient.java → .../websockets/test/TestWebSocketClient.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...sockets/test/WebSocketClientTestCase.java → ...sockets/test/WebSocketClientTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
56 changes: 56 additions & 0 deletions
56
...nt/runtime/src/main/java/io/quarkus/websockets/BearerTokenClientEndpointConfigurator.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
package io.quarkus.websockets; | ||
|
||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Map; | ||
|
||
import javax.websocket.ClientEndpointConfig; | ||
import javax.websocket.Decoder; | ||
import javax.websocket.Encoder; | ||
import javax.websocket.Extension; | ||
|
||
import io.vertx.core.http.HttpHeaders; | ||
|
||
public class BearerTokenClientEndpointConfigurator implements ClientEndpointConfig { | ||
|
||
final String token; | ||
|
||
public BearerTokenClientEndpointConfigurator(String token) { | ||
this.token = token; | ||
} | ||
|
||
@Override | ||
public List<String> getPreferredSubprotocols() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<Extension> getExtensions() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public Configurator getConfigurator() { | ||
return new Configurator() { | ||
@Override | ||
public void beforeRequest(Map<String, List<String>> headers) { | ||
headers.put(HttpHeaders.AUTHORIZATION.toString(), Collections.singletonList("Bearer " + token)); | ||
} | ||
}; | ||
} | ||
|
||
@Override | ||
public List<Class<? extends Encoder>> getEncoders() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public List<Class<? extends Decoder>> getDecoders() { | ||
return Collections.emptyList(); | ||
} | ||
|
||
@Override | ||
public Map<String, Object> getUserProperties() { | ||
return Collections.emptyMap(); | ||
} | ||
} |
2 changes: 1 addition & 1 deletion
2
...kets/client/runtime/ExecutorSupplier.java → ...kets/client/runtime/ExecutorSupplier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
23 changes: 23 additions & 0 deletions
23
...client/runtime/src/main/java/io/quarkus/websockets/client/runtime/WebSocketPrincipal.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package io.quarkus.websockets.client.runtime; | ||
|
||
import java.security.Principal; | ||
|
||
import io.quarkus.security.identity.SecurityIdentity; | ||
|
||
public class WebSocketPrincipal implements Principal { | ||
|
||
final SecurityIdentity securityIdentity; | ||
|
||
public WebSocketPrincipal(SecurityIdentity securityIdentity) { | ||
this.securityIdentity = securityIdentity; | ||
} | ||
|
||
@Override | ||
public String getName() { | ||
return securityIdentity.getPrincipal().getName(); | ||
} | ||
|
||
public SecurityIdentity getSecurityIdentity() { | ||
return securityIdentity; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...undertow/websockets/test/EchoService.java → .../quarkus/websockets/test/EchoService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...dertow/websockets/test/EchoWebSocket.java → ...uarkus/websockets/test/EchoWebSocket.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...ockets/test/WebsocketDevModeTestCase.java → ...ockets/test/WebsocketDevModeTestCase.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.