Add a token service
Some checks failed
ci/woodpecker/push/js-generate Pipeline is pending
ci/woodpecker/push/lint Pipeline is pending
ci/woodpecker/push/repo-checks Pipeline is pending
ci/woodpecker/push/go-generate Pipeline failed
ci/woodpecker/push/dart-generate Pipeline failed

Signed-off-by: Nikolai Rodionov <allanger@badhouseplants.net>
This commit is contained in:
2026-05-10 22:10:05 +02:00
parent 92ae9a7a1b
commit a00093ffc1
5 changed files with 96 additions and 239 deletions

View File

@@ -18,6 +18,8 @@ service AccountsService {
// Is email for the current account verified
rpc IsEmailVerified (IsEmailVerifiedRequest) returns (IsEmailVerifiedResponse) {}
rpc RefreshSession (google.protobuf.Empty) returns (google.protobuf.Empty) {}
// Authorize using long living tokens
rpc TokenAuthorization (google.protobuf.Empty) returns (google.protobuf.Empty) {}
}
message AccountPassword {

View File

@@ -1,93 +0,0 @@
/// This file has messages for describing applications
syntax = "proto3";
package applications;
import "google/protobuf/empty.proto";
option go_package = "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/applications";
/**
* Service for handling applications
*/
service Applications {
rpc Create(CreateOptions) returns (ApplicationFull) {}
rpc Update(UpdateOptions) returns (ApplicationFull) {}
rpc Delete(DeleteOptions) returns (google.protobuf.Empty) {}
rpc Get(GetOptions) returns (ApplicationFull) {}
rpc List(ListOptions) returns (stream ApplicationFull) {}
}
/**
User related messages
*/
message OwnerId {
string uuid = 1; // UUID of a user that is creating an environemnt
}
message Token {
string token = 1; // Token that should be used to create an environment
}
/**
Services options
*/
message CreateOptions {
ApplicationMetadata metadata = 1;
ApplicationSpec spec = 2;
OwnerId owner_id = 3;
Token token = 4;
}
message UpdateOptions {
ApplicationId id = 1;
ApplicationMetadata metadata = 2;
ApplicationSpec spec = 3;
OwnerId owner_id = 4;
Token token = 5;
}
message DeleteOptions {
ApplicationId id = 1;
ApplicationMetadata metadata = 2;
OwnerId owner_id = 3;
Token token = 4;
}
message GetOptions {
ApplicationId id = 1;
ApplicationMetadata metadata = 2;
OwnerId owner_id = 3;
Token token = 4;
}
message ListOptions {
ApplicationMetadata metadata = 1;
OwnerId owner_id = 2;
Token token = 3;
}
/**
Environment related messages
*/
message ApplicationId {
string uuid = 1;
}
message ApplicationMetadata {
string name = 1;
string description = 2;
}
message ApplicationSpec {
string application = 1;
string version = 2;
string environemnt_id = 3;
map<string, string> config = 4;
string raw_config = 5;
}
message ApplicationFull {
ApplicationMetadata metadata = 1;
ApplicationSpec spec = 2;
ApplicationId id = 3;
}

View File

@@ -1,21 +0,0 @@
syntax = "proto3";
package email;
import "google/protobuf/empty.proto";
option go_package = "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/email";
/*
* A service that should handle email validation
*/
service EmailValidation {
rpc SendRequest (RequestValidation) returns (google.protobuf.Empty) {}
rpc ValidateEmail (ConfirmValidation) returns (google.protobuf.Empty) {}
}
message RequestValidation {
string user_id = 1;
}
message ConfirmValidation {
string user_id = 1;
int32 code = 2;
}

View File

@@ -1,125 +0,0 @@
/// This file has messages for describing environments
syntax = "proto3";
package environments;
import "google/protobuf/empty.proto";
option go_package = "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/environments";
/**
* Service for handling environments
*/
service Environments {
rpc Create(CreateOptions) returns (EnvironmentFull) {}
rpc Update(UpdateOptions) returns (EnvironmentFull) {}
rpc Delete(DeleteOptions) returns (google.protobuf.Empty) {}
rpc Get(GetOptions) returns (EnvironmentFull) {}
rpc List(ListOptions) returns (stream EnvironmentFull) {}
}
/**
User related messages
*/
message OwnerId {
string uuid = 1; // UUID of a user that is creating an environemnt
}
message Token {
string token = 1; // Token that should be used to create an environment
}
/**
Services options
*/
message CreateOptions {
EnvironmentMetadata metadata = 1;
EnvironmentSpec spec = 2;
OwnerId owner_id = 3;
Token token = 4;
}
message UpdateOptions {
EnvironmentId id = 1;
EnvironmentMetadata metadata = 2;
EnvironmentSpec spec = 3;
OwnerId owner_id = 4;
Token token = 5;
}
message DeleteOptions {
EnvironmentId id = 1;
EnvironmentMetadata metadata = 2;
OwnerId owner_id = 3;
Token token = 4;
}
message GetOptions {
EnvironmentId id = 1;
EnvironmentMetadata metadata = 2;
OwnerId owner_id = 3;
Token token = 4;
}
message ListOptions {
EnvironmentMetadata metadata = 1;
string search_string = 2;
OwnerId owner_id = 3;
Token token = 4;
}
/**
Environment related messages
*/
message EnvironmentId {
string uuid = 1;
}
message EnvironmentMetadata {
string name = 1; // A name of the environment
string description = 2;
}
message EnvironmentSpec {
Provider provider = 1; // Provide
Kubernetes kubernetes = 2;
ServerType server_type = 3;
Location server_location = 4;
int32 disk_size = 5;
}
message EnvironmentFull {
EnvironmentMetadata metadata = 1;
EnvironmentSpec spec = 2;
EnvironmentId id = 3;
}
/**
Helpers and other messages
*/
enum Provider {
PROVIDER_UNSPECIFIED = 0;
PROVIDER_HETZNER = 1;
}
enum ServerType {
SERVER_TYPE_UNSPECIFIED = 0;
SERVER_TYPE_STARTER = 1;
SERVER_TYPE_REGULAR = 2;
SERVER_TYPE_PLUS = 3;
SERVER_TYPE_PRO = 4;
SERVER_TYPE_CUSTOM = 5;
}
enum Location {
LOCATION_UNSPECIFIED = 0;
LOCATION_HETZNER_NUREMBERG = 1;
LOCATION_HETZNER_FALKENSTEIN = 2;
LOCATION_HETZNER_HELSINKI = 3;
LOCATION_HETZNER_HILLSBORO = 4;
LOCATION_HETZNER_ASHBURN = 5;
}
enum Kubernetes {
KUBERNETES_UNSPECIFIED = 0;
KUBERNETES_K3S = 1;
}

View File

@@ -0,0 +1,94 @@
/// Protobuf definitions for the accounts service.
syntax = "proto3";
package tokens.v1;
import "google/protobuf/empty.proto";
import "google/protobuf/timestamp.proto";
option go_package = "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/tokens/v1";
// Tokens should be used for programmatic access
// For example CLI or terraform modules
service TokensService {
// Create a new token
rpc CreateToken (CreateTokenRequest) returns (CreateTokenResponse) {}
// Update an existing token
rpc UpdateToken (UpdateTokenRequest) returns (UpdateTokenResponse) {}
// Expire an existing token
rpc ForceTokenExpiration (ForceTokenExpirationRequest) returns (google.protobuf.Empty) {}
// Create a new token with the same UUID
rpc RegenerateToken (RegenerateTokenRequest) returns (RegenerateTokenResponse) {}
// Get an existing token
rpc GetToken (GetTokenRequest) returns (GetTokenResponse) {}
// List all existing tokens
rpc ListTokens (google.protobuf.Empty) returns (stream ListTokensResponse) {}
}
message TokenMetadata {
// A token name
string name = 1;
// Token expiration timestamp
google.protobuf.Timestamp expires_at = 2;
}
message TokenUUID {
// An ID of a token
string uuid = 1;
}
message TokenValue {
// Token value
// Can be only retrieved once after the generation
string token = 1;
}
message TokenPermissions {}
message CreateTokenRequest {
TokenMetadata token_metadata = 1;
TokenPermissions token_permissions = 2;
}
message CreateTokenResponse {
TokenUUID token_uuid = 1;
TokenMetadata token_metadata = 2;
TokenPermissions token_permissions = 3;
TokenValue token_value = 4;
}
message UpdateTokenRequest {
TokenUUID token_uuid = 1;
TokenMetadata token_metadata = 2;
TokenPermissions token_permissions = 3;
}
message UpdateTokenResponse {
TokenUUID token_uuid = 1;
TokenMetadata token_metadata = 2;
TokenPermissions token_permissions = 3;
}
message ForceTokenExpirationRequest {
TokenUUID token_uuid = 1;
}
message RegenerateTokenRequest {
TokenUUID token_uuid = 1;
}
message RegenerateTokenResponse {
TokenValue token_value = 1;
}
message GetTokenRequest {
TokenUUID token_uuid = 1;
}
message GetTokenResponse {
TokenUUID token_uuid = 1;
TokenMetadata token_metadata = 2;
TokenPermissions token_permissions = 3;
}
message ListTokensResponse {
TokenUUID token_uuid = 1;
TokenMetadata token_metadata = 2;
TokenPermissions token_permissions = 3;
}