From 35c6689a2c0ac37bfae1c1370bf5d4a532a340ef Mon Sep 17 00:00:00 2001 From: Nikolai Rodionov Date: Tue, 12 May 2026 16:42:24 +0200 Subject: [PATCH] Start implementing the tokens controller Signed-off-by: Nikolai Rodionov --- api/v1/tokens.go | 9 ++++++ internal/controllers/tokens.go | 53 ++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 api/v1/tokens.go create mode 100644 internal/controllers/tokens.go diff --git a/api/v1/tokens.go b/api/v1/tokens.go new file mode 100644 index 0000000..4c115eb --- /dev/null +++ b/api/v1/tokens.go @@ -0,0 +1,9 @@ +package v1 + +import ( + tokens "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/tokens/v1" +) + +type TokensServer struct { + tokens.UnimplementedTokensServiceServer +} diff --git a/internal/controllers/tokens.go b/internal/controllers/tokens.go new file mode 100644 index 0000000..5789702 --- /dev/null +++ b/internal/controllers/tokens.go @@ -0,0 +1,53 @@ +package controllers + +import ( + "context" + "database/sql" + "time" +) + +type TokenController struct { + DB *sql.DB +} + +type TokenData struct { + UUID string + UserID string + CreatedAt time.Time + LastUserAt time.Time + RevokedAt time.Time + ExpiredAt time.Time + Scopes *Scopes +} + +type Scopes struct{} + +// Create a new token, store its hash in the database and return the token value +func (ctrl *TokenController) Create(ctx context.Context) (string, error) { + return "", nil +} + +// Update token name or permissions, other changes are ignored by this method +func (ctrl *TokenController) Update(ctx context.Context) (string, error) { + return "", nil +} + +// ForceExpiration of a token, so it can no longer be used +func (ctrl *TokenController) ForceExpiration(ctx context.Context) error { + return nil +} + +// Regenerate a token and get a new value +func (ctrl *TokenController) Regenerate(ctx context.Context) (string, error) { + return "", nil +} + +// Get an existing token data +func (ctrl *TokenController) Get(ctx context.Context, uuid string) error { + return nil +} + +// List all available token +func (ctrl *TokenController) List(ctx context.Context) error { + return nil +}