add oauth proto file
All checks were successful
Publish / Publish Job (push) Successful in 2m30s

This commit is contained in:
Дмитрий
2026-04-23 10:46:34 +03:00
parent 28f8834c7b
commit 5847a6e560
4 changed files with 106 additions and 27 deletions

View File

@@ -1,6 +1,6 @@
{
"name": "@lendry-erp/contracts",
"version": "1.2.37",
"version": "1.2.38",
"description": "Protobuf definitions and generated TypeScript types",
"type": "commonjs",
"main": "./dist/index.js",

View File

@@ -14,9 +14,6 @@ service AuthService {
rpc GetSessions(GetSessionRequest) returns (GetSessionsResponse);
rpc TerminateSession(TerminateSessionRequest) returns (TerminateSessionResponse);
// === OAuth2 SSO ===
rpc GenerateOauthCode (GenerateOauthCodeRequest) returns (GenerateOauthCodeResponse);
rpc ExchangeOauthCode (ExchangeOauthCodeRequest) returns (ExchangeOauthCodeResponse);
// Системные методы для админа
rpc SystemCreateAccount (SystemCreateAccountRequest) returns (SystemCreateAccountResponse);
@@ -118,29 +115,6 @@ message TerminateSessionResponse {
}
// === Сообщения для OAuth2 SSO ===
message GenerateOauthCodeRequest {
string user_id = 1;
string client_id = 2;
string redirect_uri = 3;
}
message GenerateOauthCodeResponse {
string code = 1;
}
message ExchangeOauthCodeRequest {
string code = 1;
string client_id = 2;
string client_secret = 3;
}
message ExchangeOauthCodeResponse {
string access_token = 1;
int32 expires_in = 2;
}
message SystemCreateAccountRequest {
string username = 1;
string password_hash = 2; // Хеш пароля генерирует Admin Service и передает сюда

104
proto/sso/oauth.proto Normal file
View File

@@ -0,0 +1,104 @@
syntax = "proto3";
package oauth.v1;
option go_package = "git.lendry.ru/lendry-erp/proto.git/go;pb";
service OauthService {
// === Базовый SSO (вызывается из Gateway / Графаны) ===
rpc GenerateOauthCode (GenerateOauthCodeRequest) returns (GenerateOauthCodeResponse);
rpc ExchangeOauthCode (ExchangeOauthCodeRequest) returns (ExchangeOauthCodeResponse);
// === Системные методы для Админки (Управление клиентами) ===
rpc SystemCreateOauthClient (SystemCreateOauthClientRequest) returns (SystemCreateOauthClientResponse);
rpc SystemGetOauthClients (SystemGetOauthClientsRequest) returns (SystemGetOauthClientsResponse);
rpc SystemUpdateOauthClient (SystemUpdateOauthClientRequest) returns (SystemUpdateOauthClientResponse);
rpc SystemResetOauthSecret (SystemResetOauthSecretRequest) returns (SystemResetOauthSecretResponse);
rpc SystemDeleteOauthClient (SystemDeleteOauthClientRequest) returns (SystemDeleteOauthClientResponse);
}
// --- Сообщения для базового SSO ---
message GenerateOauthCodeRequest {
string user_id = 1;
string client_id = 2;
string redirect_uri = 3;
}
message GenerateOauthCodeResponse {
string code = 1;
}
message ExchangeOauthCodeRequest {
string code = 1;
string client_id = 2;
string client_secret = 3;
}
message ExchangeOauthCodeResponse {
string access_token = 1;
int32 expires_in = 2;
}
// --- Сообщения для управления клиентами (Yandex/Google style) ---
message SystemCreateOauthClientRequest {
string name = 1; // Название приложения (например, "Grafana Analytics")
repeated string redirect_uris = 2; // Список разрешенных коллбеков
optional string description = 3; // Описание (для админки)
}
message SystemCreateOauthClientResponse {
string id = 1; // Внутренний ID в базе
string name = 2;
string client_id = 3; // Публичный ID клиента (app_...)
string plain_secret = 4; // ВАЖНО: Чистый секрет. Отдается ТОЛЬКО здесь один раз!
repeated string redirect_uris = 5;
}
message OauthClientItem {
string id = 1;
string name = 2;
string client_id = 3;
repeated string redirect_uris = 4;
optional string description = 5;
int64 created_at = 6;
// Обратите внимание: поля secret здесь нет! Секрет нельзя получить списком.
}
message SystemGetOauthClientsRequest {
int32 limit = 1;
int32 offset = 2;
}
message SystemGetOauthClientsResponse {
repeated OauthClientItem clients = 1;
int32 total = 2;
}
message SystemUpdateOauthClientRequest {
string client_id = 1;
optional string name = 2;
repeated string redirect_uris = 3; // Если передано, полностью перезаписывает старые
optional string description = 4;
}
message SystemUpdateOauthClientResponse {
bool success = 1;
}
message SystemResetOauthSecretRequest {
string client_id = 1;
}
message SystemResetOauthSecretResponse {
string new_plain_secret = 1; // Возвращаем новый сгенерированный секрет
}
message SystemDeleteOauthClientRequest {
string client_id = 1;
}
message SystemDeleteOauthClientResponse {
bool success = 1;
}

View File

@@ -5,6 +5,7 @@ export const PROTO_PATHS = {
LDAP_AUTH: join(__dirname, "../../proto/sso/ldap-auth.proto"),
ACCOUNT: join(__dirname, "../../proto/sso/account.proto"),
TWOFA: join(__dirname, "../../proto/sso/twofa.proto"),
OAUTH: join(__dirname, "../../proto/sso/oauth.proto"),
ADMIN: join(__dirname, "../../proto/admin/admin-account.proto"),
RBAC: join(__dirname, "../../proto/admin/rbac.proto"),
USERS: join(__dirname, "../../proto/users/users.proto"),