Skip to content

Commit

Permalink
Check for capability feature "federation-v2" for federated connections.
Browse files Browse the repository at this point in the history
  • Loading branch information
fancycode committed Jul 24, 2024
1 parent 16ee3c9 commit f064471
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 0 deletions.
3 changes: 3 additions & 0 deletions capabilities.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ const (
// Name of capability to enable the "v3" API for the signaling endpoint.
FeatureSignalingV3Api = "signaling-v3"

// Name of capability that is set if the server supports Federation V2.
FeatureFederationV2 = "federation-v2"

// Cache received capabilities for one hour.
CapabilitiesCacheDuration = time.Hour

Expand Down
4 changes: 4 additions & 0 deletions hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -1282,6 +1282,10 @@ func (h *Hub) processHelloV2(ctx context.Context, client HandlerClient, message
tokenString = message.Hello.Auth.helloV2Params.Token
tokenClaims = &HelloV2TokenClaims{}
case HelloClientTypeFederation:
if !h.backend.capabilities.HasCapabilityFeature(ctx, url, FeatureFederationV2) {
return nil, nil, ErrFederationNotSupported
}

tokenString = message.Hello.Auth.federationParams.Token
tokenClaims = &FederationTokenClaims{}
default:
Expand Down
3 changes: 3 additions & 0 deletions hub_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -699,6 +699,9 @@ func registerBackendHandlerUrl(t *testing.T, router *mux.Router, url string) {
if strings.Contains(t.Name(), "V3Api") {
features = append(features, "signaling-v3")
}
if strings.Contains(t.Name(), "Federation") {
features = append(features, "federation-v2")
}
signaling := map[string]interface{}{
"foo": "bar",
"baz": 42,
Expand Down

0 comments on commit f064471

Please sign in to comment.