Check for capability feature "federation-v2" for federated connections.

This commit is contained in:
Joachim Bauch 2024-07-24 12:21:39 +02:00
commit fd651d7213
No known key found for this signature in database
GPG key ID: 77C1D22D53E15F02
3 changed files with 10 additions and 0 deletions

View file

@ -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.

4
hub.go
View file

@ -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:

View file

@ -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,