This commit is contained in:
104
proto/sso/oauth.proto
Normal file
104
proto/sso/oauth.proto
Normal 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;
|
||||
}
|
||||
Reference in New Issue
Block a user