Account and auth protobuf and client code

This commit is contained in:
2025-07-06 21:47:23 +08:00
parent 5757526ea5
commit bb2f88cc54
10 changed files with 400 additions and 0 deletions

View File

@ -0,0 +1,22 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
</PropertyGroup>
<ItemGroup>
<Protobuf Include="Protos\*.proto" GrpcServices="Client" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="Grpc.Net.Client" Version="2.65.0" />
<PackageReference Include="Google.Protobuf" Version="3.27.2" />
<PackageReference Include="Grpc.Tools" Version="2.65.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
</Project>

View File

@ -0,0 +1,28 @@
syntax = "proto3";
package dyson_network.sphere.account;
import "google/protobuf/empty.proto";
option csharp_namespace = "DysonNetwork.Sphere.Account.Proto";
service AccountService {
// Retrieves the current user's account information
rpc GetAccount(google.protobuf.Empty) returns (AccountResponse);
// Updates the current user's account information
rpc UpdateAccount(UpdateAccountRequest) returns (AccountResponse);
}
message AccountResponse {
string id = 1;
string username = 2;
string email = 3;
string display_name = 4;
}
message UpdateAccountRequest {
// Fields to update
optional string email = 1;
optional string display_name = 2;
}

View File

@ -0,0 +1,55 @@
syntax = "proto3";
package dyson_network.sphere.auth;
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
option csharp_namespace = "DysonNetwork.Sphere.Auth.Proto";
service AuthService {
// Standard username/password login
rpc Login(LoginRequest) returns (LoginResponse);
// Introspects an OAuth 2.0 access token.
rpc IntrospectToken(IntrospectTokenRequest) returns (IntrospectionResponse);
// Logs out the current session
rpc Logout(google.protobuf.Empty) returns (google.protobuf.Empty);
}
message LoginRequest {
string username = 1;
string password = 2;
// Optional: for 2FA
string two_factor_code = 3;
}
message LoginResponse {
string access_token = 1;
string refresh_token = 2;
int64 expires_in = 3;
}
message IntrospectTokenRequest {
string token = 1;
// Optional: token_type_hint can be "access_token" or "refresh_token"
string token_type_hint = 2;
}
message IntrospectionResponse {
// Indicates whether or not the token is currently active.
bool active = 1;
// A JSON string containing the claims of the token.
string claims = 2;
// The client identifier for the OAuth 2.0 client that requested the token.
string client_id = 3;
// The username of the resource owner who authorized the token.
string username = 4;
// The scope of the access token.
string scope = 5;
// The time at which the token was issued.
google.protobuf.Timestamp iat = 6;
// The time at which the token expires.
google.protobuf.Timestamp exp = 7;
}