Start implementing the tokens controller

Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
This commit is contained in:
2026-05-12 16:42:24 +02:00
parent 7f6260669a
commit 35c6689a2c
2 changed files with 62 additions and 0 deletions

9
api/v1/tokens.go Normal file
View File

@@ -0,0 +1,9 @@
package v1
import (
tokens "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/tokens/v1"
)
type TokensServer struct {
tokens.UnimplementedTokensServiceServer
}

View File

@@ -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
}