Start implementing the tokens controller
Signed-off-by: Nikolai Rodionov <iam@allanger.xyz>
This commit is contained in:
9
api/v1/tokens.go
Normal file
9
api/v1/tokens.go
Normal file
@@ -0,0 +1,9 @@
|
||||
package v1
|
||||
|
||||
import (
|
||||
tokens "gitea.badhouseplants.net/softplayer/softplayer-go-proto/pkg/tokens/v1"
|
||||
)
|
||||
|
||||
type TokensServer struct {
|
||||
tokens.UnimplementedTokensServiceServer
|
||||
}
|
||||
53
internal/controllers/tokens.go
Normal file
53
internal/controllers/tokens.go
Normal 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
|
||||
}
|
||||
Reference in New Issue
Block a user