You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A build item that allows extensions to register additional resources that should be available from the ClassLoader at runtime.
36
+
These resources are typically generated or discovered during the build process and are not located in the standard `src/main/resources` directory. Multiple instances of this build item can be produced, and all registered resources will be aggregated.
37
+
The key of the map represents the resource path (e.g., `META-INF/my-config.properties` ), and the value is the byte content of the resource.
36
38
-- a|`java.util.Map<String,byte[]> resources`
37
39
38
-
_No Javadoc found_
40
+
A map where keys are resource paths and values are the corresponding resource content as byte arrays.
For the broker to advertise its externally accessible address to clients, it requires an additional file `kafka.sh` as described in xref:compose-dev-services.adoc#exposing-port-mappings-to-running-containers[Exposing port mappings to running containers].
Copy file name to clipboardExpand all lines: _versions/main/guides/websockets-next-reference.adoc
+95Lines changed: 95 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1070,6 +1070,101 @@ When you plan to use bearer access tokens during the opening WebSocket handshake
1070
1070
* Use a custom WebSocket ticket system which supplies a random token with the HTML page which hosts the JavaScript WebSockets client which must provide this token during the initial handshake request as a query parameter.
1071
1071
====
1072
1072
1073
+
Before the bearer access token sent on the initial HTTP request expires, you can send a new bearer access token as part of a message and update current `SecurityIdentity` attached to the WebSocket server connection:
<1> Asynchronously update the `SecurityIdentity` attached to the WebSocket server connection.
1111
+
<2> The current `SecurityIdentity` instance is still available and can be used during the `SecurityIdentity` update.
1112
+
1113
+
The xref:security-oidc-bearer-token-authentication.adoc[OIDC Bearer token authentication] mechanism has builtin support for the `SecurityIdentity` update.
1114
+
If you use other authentication mechanisms, you must implement the `io.quarkus.security.identity.IdentityProvider` provider that supports the `io.quarkus.websockets.next.runtime.spi.security.WebSocketIdentityUpdateRequest` authentication request.
1115
+
1116
+
[IMPORTANT]
1117
+
====
1118
+
The new bearer access token must have the same `sub` claim value as the token used during the initial HTTP request.
1119
+
Please also make sure the `SecurityIdentity` is only updated when necessary and the WebSocket message with credentials do not appear in your application logs.
1120
+
Always use the `wss` protocol to enforce encrypted HTTP connection via TLS when sending credentials as part of the WebSocket message.
1121
+
====
1122
+
1123
+
WebSocket client application have to send a new access token before previous one expires:
1124
+
1125
+
[source,html]
1126
+
----
1127
+
<script type="module">
1128
+
import Keycloak from 'https://cdn.jsdelivr.net/npm/[email protected]/lib/keycloak.js'
1129
+
const keycloak = new Keycloak({
1130
+
url: 'http://localhost:39245',
1131
+
realm: 'quarkus',
1132
+
clientId: 'websockets-js-client'
1133
+
});
1134
+
function getToken() {
1135
+
return keycloak.token
1136
+
}
1137
+
1138
+
await keycloak
1139
+
.init({onLoad: 'login-required'})
1140
+
.then(() => console.log('User is now authenticated.'))
1141
+
.catch(err => console.log('User is NOT authenticated.', err));
const socket = new WebSocket("wss://" + location.host + "/chat/username", subprotocols);
1147
+
1148
+
setInterval(() => {
1149
+
keycloak
1150
+
.updateToken(15)
1151
+
.then(result => {
1152
+
if (result && connectionOpened) {
1153
+
console.log('Token updated, sending new token to the server')
1154
+
socket.send(JSON.stringify({
1155
+
metadata: {
1156
+
token: `${getToken()}`
1157
+
}
1158
+
}));
1159
+
}
1160
+
})
1161
+
.catch(err => console.error(err))
1162
+
}, 10000);
1163
+
</script>
1164
+
----
1165
+
1166
+
Complete example is located in the `security-openid-connect-websockets-next-quickstart` link:{quickstarts-tree-url}/security-openid-connect-websockets-next-quickstart[directory].
1167
+
1073
1168
=== Inspect and/or reject HTTP upgrade
1074
1169
1075
1170
To inspect an HTTP upgrade, you must provide a CDI bean implementing the `io.quarkus.websockets.next.HttpUpgradeCheck` interface.
0 commit comments