Skip to content

Web PubSub: GenerateClientAccessURL generates invalid tokens #27414

Description

Bug Report

  • import path of package in question: github.com/Azure/azure-sdk-for-go/sdk/messaging/azwebpubsub
  • SDK version: 0.1.1
  • output of go version: go version go1.26.6 darwin/arm64
  • What happened?

The SDK incorrectly sets the audience of the JWT to a host using the same scheme as the HTTP API (i.e. http or https). This yields JWTs that are rejected by the server. The expected scheme for the audience field is wss. This has essentially made the SDK unusable for generating client access URLs since its conception.

audience := fmt.Sprintf("%sclient/hubs/%s", parsedURL.String(), hubPath)
parsedURL.Scheme = strings.Replace(strings.ToLower(parsedURL.Scheme), "http", "ws", 1)
baseURL := fmt.Sprintf("%sclient/hubs/%s", parsedURL.String(), hubPath)
var token string
if c.key != nil {
token, err = c.signJwtToken(audience, options)

  • What did you expect or want to happen?

The SDK should generate tokens and URLs that work with a WebSocket client without the server returning 401 Forbidden. The clients using a token or URL should be able to connect successfully.

  • How can we reproduce it?

Just test using GenerateClientAccessURL. It will return a JWT with an aud set to https://... when it should be wss. This can be confirmed by connecting to a server, which will reject the request.

  • Anything we should know about your environment.

Web PubSub Service SKU Premium P1, version 1.0.

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.WebPubSubcustomer-reportedIssues that are reported by GitHub users external to the Azure organization.needs-team-attentionWorkflow: This issue needs attention from Azure service team or SDK teamquestionThe issue doesn't require a change to the product in order to be resolved. Most issues start as that

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions