Browse Source
The on-prem token provider rejected a localhost origin on every TB AI call, so usage info, the solution creator and the WebSocket channel failed without a configured base URL. TB AI only calls TB back at that origin on the legacy HTTP paths, so the check now runs only before SSE chat and the HTTP fallback of solution and dashboard operations.pull/16336/head
9 changed files with 143 additions and 17 deletions
@ -0,0 +1,27 @@ |
|||
// SPDX-FileCopyrightText: Copyright ThingsBoard, Inc.
|
|||
// SPDX-License-Identifier: BUSL-1.1
|
|||
package org.thingsboard.server.service.ai.transport; |
|||
|
|||
import lombok.RequiredArgsConstructor; |
|||
import org.springframework.stereotype.Component; |
|||
import org.thingsboard.server.queue.util.TbCoreComponent; |
|||
import org.thingsboard.server.service.ai.TbAiTokenProvider; |
|||
import org.thingsboard.server.service.security.model.SecurityUser; |
|||
|
|||
import java.util.Optional; |
|||
|
|||
/** |
|||
* Guards the legacy HTTP paths, where TB AI calls back the origin sent with the token. |
|||
*/ |
|||
@Component |
|||
@TbCoreComponent |
|||
@RequiredArgsConstructor |
|||
class TbAiCallbackOriginValidator { |
|||
|
|||
private final Optional<TbAiTokenProvider> tokenProvider; |
|||
|
|||
void validate(SecurityUser user) { |
|||
tokenProvider.ifPresent(provider -> provider.validateCallbackOrigin(user)); |
|||
} |
|||
|
|||
} |
|||
Loading…
Reference in new issue