syntax = "proto3";

package next_edu_cloud.iam.v1;

// IamService 定义身份与访问管理契约
// P2: REST 实现，P3 起转 gRPC
service IamService {
  rpc Register(RegisterRequest) returns (AuthResponse);
  rpc Login(LoginRequest) returns (AuthResponse);
  rpc RefreshToken(RefreshTokenRequest) returns (TokenPair);
  rpc GetUserInfo(GetUserInfoRequest) returns (UserInfo);
}

message RegisterRequest {
  string email = 1;
  string password = 2;
  string name = 3;
}

message LoginRequest {
  string email = 1;
  string password = 2;
}

message RefreshTokenRequest {
  string refresh_token = 1;
}

message GetUserInfoRequest {
  string user_id = 1;
}

message AuthResponse {
  UserInfo user = 1;
  TokenPair tokens = 2;
}

message TokenPair {
  string access_token = 1;
  string refresh_token = 2;
  int32 expires_in = 3;
}

message UserInfo {
  string id = 1;
  string email = 2;
  string name = 3;
  repeated string roles = 4;
  repeated string permissions = 5;
}
