style: перевести комментарии на русский, убрать очевидные
This commit is contained in:
1 parent
ada9b949a4
commit
e417dac087
48 files changed
+659
-671
No files matched your search
+15
-19
@@ -5,39 +5,35 @@ import (
|
||||
"net"
|
||||
)
|
||||
|
||||
// TenantID identifies a tenant in a multi-tenant deployment.
|
||||
// The zero value ("") is the [Anonymous] sentinel used in single-tenant mode.
|
||||
// TenantID идентифицирует тенанта в multi-tenant конфигурации.
|
||||
// Нулевое значение ("") — sentinel [Anonymous] для single-tenant режима.
|
||||
type TenantID string
|
||||
|
||||
// Anonymous is the sentinel TenantID used when authentication is disabled
|
||||
// (single-tenant / no-op mode). All call-sites pass this value until a real
|
||||
// Authenticator is wired in.
|
||||
// Anonymous — sentinel TenantID, когда аутентификация выключена
|
||||
// (single-tenant / no-op). Все вызовы передают это значение, пока
|
||||
// настоящий Authenticator не подключён.
|
||||
const Anonymous TenantID = ""
|
||||
|
||||
// Authenticator authenticates an incoming connection and returns the
|
||||
// TenantID it belongs to. Implementations must be safe for concurrent use.
|
||||
// Authenticator аутентифицирует входящее соединение и возвращает TenantID.
|
||||
// Реализации обязаны быть конкурентно безопасны.
|
||||
//
|
||||
// A nil error with [Anonymous] means the connection is accepted in
|
||||
// non-multi-tenant mode. Any non-nil error must be treated as a rejection
|
||||
// and the caller must close conn.
|
||||
// nil ошибка с [Anonymous] означает приём в не-multi-tenant режиме.
|
||||
// Любая не-nil ошибка трактуется как отказ; вызывающий обязан закрыть conn.
|
||||
//
|
||||
// This interface is stream-oriented: it consumes a net.Conn and is intended
|
||||
// for bondserver/tcpfwdserver wiring. UDP-mode auth (when needed) will get
|
||||
// a separate interface taking a token []byte read out-of-band from the
|
||||
// handshake, since udpserver has no per-tenant stream abstraction.
|
||||
// Интерфейс ориентирован на потоки (net.Conn) — для bondserver/tcpfwdserver.
|
||||
// UDP-режиму (если потребуется) нужен отдельный интерфейс с токеном из
|
||||
// out-of-band handshake, т.к. в udpserver нет per-tenant абстракции потока.
|
||||
type Authenticator interface {
|
||||
Authenticate(ctx context.Context, conn net.Conn) (TenantID, error)
|
||||
}
|
||||
|
||||
// NopAuthenticator is a no-op Authenticator that always returns [Anonymous].
|
||||
// It is the default when multi-tenant support is not configured.
|
||||
// NopAuthenticator — no-op Authenticator, всегда возвращает [Anonymous].
|
||||
// Используется по умолчанию, когда multi-tenant не настроен.
|
||||
type NopAuthenticator struct{}
|
||||
|
||||
// compile-time interface check.
|
||||
var _ Authenticator = NopAuthenticator{}
|
||||
|
||||
// Authenticate implements [Authenticator]. It always succeeds and returns
|
||||
// [Anonymous] without inspecting conn or ctx.
|
||||
// Authenticate реализует [Authenticator]: всегда успех и [Anonymous].
|
||||
func (NopAuthenticator) Authenticate(_ context.Context, _ net.Conn) (TenantID, error) {
|
||||
return Anonymous, nil
|
||||
}
|
||||
+16
-17
@@ -1,23 +1,22 @@
|
||||
// Package auth defines the Authenticator interface and tenant identity types
|
||||
// for multi-tenant support.
|
||||
// Package auth определяет интерфейс Authenticator и типы идентификации тенантов
|
||||
// для multi-tenant конфигурации.
|
||||
//
|
||||
// # Current state
|
||||
// # Текущее состояние
|
||||
//
|
||||
// Only the scaffold is present. The [NopAuthenticator] is used everywhere and
|
||||
// returns [Anonymous], preserving existing single-tenant behaviour.
|
||||
// Реализован только каркас. Везде используется [NopAuthenticator] —
|
||||
// возвращает [Anonymous], сохраняя single-tenant поведение.
|
||||
//
|
||||
// # Planned multi-tenant flow
|
||||
// # Планируемый multi-tenant поток
|
||||
//
|
||||
// 1. A real Authenticator (e.g. HMACAuthenticator backed by SQLite) reads a
|
||||
// short token from the first bytes of conn, validates it against a per-tenant
|
||||
// shared secret, and returns the matching [TenantID].
|
||||
// 2. bondserver.Registry uses the TenantID as part of its de-duplication key so
|
||||
// ConnIDs from different tenants never collide.
|
||||
// 3. tcpfwdserver and udpserver resolve connectAddr per-tenant, allowing each
|
||||
// tenant to target a different backend.
|
||||
// 4. Deep-link provisioning delivers per-tenant secrets to mobile clients without
|
||||
// manual configuration.
|
||||
// 1. Реальный Authenticator (например HMACAuthenticator поверх SQLite) читает
|
||||
// короткий токен из первых байт conn, проверяет его против per-tenant
|
||||
// общего секрета и возвращает соответствующий [TenantID].
|
||||
// 2. bondserver.Registry использует TenantID как часть ключа дедупликации —
|
||||
// ConnID разных тенантов не пересекаются.
|
||||
// 3. tcpfwdserver и udpserver резолвят connectAddr per-tenant — каждый тенант
|
||||
// указывает на свой backend.
|
||||
// 4. Deep-link provisioning доставляет per-tenant секреты мобильным клиентам
|
||||
// без ручной настройки.
|
||||
//
|
||||
// None of the items above are implemented yet. See notes/AUTH_PLAN.md for the
|
||||
// detailed design.
|
||||
// Ничего из перечисленного пока не реализовано. См. notes/AUTH_PLAN.md.
|
||||
package auth
|
||||
Reference in new issue
Block a user