diff --git a/capabilities.go b/capabilities.go index 433b15c..45b7b54 100644 --- a/capabilities.go +++ b/capabilities.go @@ -43,6 +43,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" + // minCapabilitiesCacheDuration specifies the minimum duration to cache // capabilities. // This could overwrite the "max-age" from a "Cache-Control" header. diff --git a/hub.go b/hub.go index d7b1775..05a7d5d 100644 --- a/hub.go +++ b/hub.go @@ -1281,6 +1281,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: diff --git a/hub_test.go b/hub_test.go index 2f75e79..3cf8ea2 100644 --- a/hub_test.go +++ b/hub_test.go @@ -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,