feat: hand over additional headers to websocket upgrade request handl…#49623
Conversation
…ing so customEndpointAddress() instances that need authorization can be provided one.
|
Thank you for your contribution @thorbenheins! We will review the pull request and get back to you soon. |
|
@thorbenheins please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
2 similar comments
|
@thorbenheins please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
|
@thorbenheins please read the following Contributor License Agreement(CLA). If you agree with the CLA, please reply with the following information.
Contributor License AgreementContribution License AgreementThis Contribution License Agreement (“Agreement”) is agreed to by the party signing below (“You”),
|
There was a problem hiding this comment.
Pull request overview
This PR updates the AMQP-over-WebSockets connection path in azure-core-amqp to pass additional ClientOptions headers into the initial WebSocket HTTP Upgrade request, enabling scenarios like forwarding an Authorization header when using customEndpointAddress() (e.g., with Service Bus).
Changes:
- Forward
ClientOptionsheaders intoWebSocketImpl.configure(...)for WebSocket upgrade requests. - Relax
ConnectionHandler’sconnectionOptionsfield visibility to enable access from WebSocket-related subclasses.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/handler/WebSocketsConnectionHandler.java | Builds and passes a header map from ClientOptions into the WebSocket upgrade configuration. |
| sdk/core/azure-core-amqp/src/main/java/com/azure/core/amqp/implementation/handler/ConnectionHandler.java | Changes connectionOptions visibility to protected so subclasses can read it. |
| final Map<String, String> headers = connectionOptions != null && connectionOptions.getClientOptions().getHeaders() != null | ||
| ? StreamSupport.stream(connectionOptions.getClientOptions().getHeaders().spliterator(), false) | ||
| .collect(Collectors.toMap(Header::getName, Header::getValue)) | ||
| : null; |
| private final Map<String, Object> connectionProperties; | ||
| private final ConnectionOptions connectionOptions; | ||
| protected final ConnectionOptions connectionOptions; | ||
| private final SslPeerDetails peerDetails; | ||
| private final AmqpMetricsProvider metricProvider; |
| webSocket.configure(hostname, SOCKET_PATH, "", 0, PROTOCOL, headers, null); | ||
|
|
We want to use the customEndpointAddress() feature of the ServiceBusClient and need to add an Authorization Header containing the JWT being used downstream to the WebSocket upgrade request. Currently the request does not map the add the addtional headers being configured when constructing the client to this initial request.
Making the ConnectionOptions protected might be unacceptable, not sure. One could also add a getter or similar that only grants access to the headers and not all the other options in there.
Description
see above.