Add realtime gateway and simulator bridge

This commit is contained in:
2026-03-27 21:06:17 +08:00
parent 0703fd47a2
commit 2c0fd4c549
36 changed files with 6852 additions and 1 deletions

View File

@@ -0,0 +1,24 @@
package gateway
import (
"slices"
"realtime-gateway/internal/config"
"realtime-gateway/internal/model"
)
func authorize(cfg config.AuthConfig, role model.Role, token string) bool {
switch role {
case model.RoleProducer:
return slices.Contains(cfg.ProducerTokens, token)
case model.RoleController:
return slices.Contains(cfg.ControllerTokens, token)
case model.RoleConsumer:
if cfg.AllowAnonymousConsumers && token == "" {
return true
}
return slices.Contains(cfg.ConsumerTokens, token)
default:
return false
}
}