64 lines
1.5 KiB
Protocol Buffer
64 lines
1.5 KiB
Protocol Buffer
// proto/auth.proto
|
|
syntax = "proto3";
|
|
package komp_ac.auth;
|
|
|
|
import "common.proto";
|
|
|
|
service AuthService {
|
|
rpc Register(RegisterRequest) returns (AuthResponse);
|
|
rpc Login(LoginRequest) returns (LoginResponse);
|
|
rpc GetAuthorization(GetAuthorizationRequest) returns (AuthorizationSnapshot);
|
|
rpc SetTimezone(SetTimezoneRequest) returns (UserPreferences);
|
|
}
|
|
|
|
message RegisterRequest {
|
|
string username = 1;
|
|
string email = 2;
|
|
string password = 3;
|
|
string password_confirmation = 4;
|
|
string role = 5;
|
|
}
|
|
|
|
message AuthResponse {
|
|
string id = 1; // UUID in string format
|
|
string username = 2; // Registered username
|
|
string email = 3; // Registered email (if provided)
|
|
string role = 4; // Default role: 'accountant'
|
|
}
|
|
|
|
message LoginRequest {
|
|
string identifier = 1; // Can be username or email
|
|
string password = 2;
|
|
}
|
|
|
|
message LoginResponse {
|
|
string access_token = 1; // JWT token
|
|
string token_type = 2; // Usually "Bearer"
|
|
int32 expires_in = 3; // Expiration in seconds (86400 for 24 hours)
|
|
string user_id = 4; // User's UUID in string format
|
|
string role = 5; // User's role
|
|
string username = 6;
|
|
AuthorizationSnapshot authorization = 7;
|
|
string timezone = 8;
|
|
}
|
|
|
|
message SetTimezoneRequest {
|
|
string timezone = 1; // IANA timezone, for example Europe/Bratislava
|
|
}
|
|
|
|
message UserPreferences {
|
|
string timezone = 1;
|
|
}
|
|
|
|
message GetAuthorizationRequest {}
|
|
|
|
message Permission {
|
|
string resource = 1;
|
|
string action = 2;
|
|
}
|
|
|
|
message AuthorizationSnapshot {
|
|
string role = 1;
|
|
repeated Permission permissions = 2;
|
|
}
|