Feat v0.7.7 api tokens ext permissions (#61)
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m48s
CI/CD / test-sqlite (push) Successful in 2m49s
CI/CD / build-and-deploy (push) Successful in 28s
All checks were successful
CI/CD / detect-changes (push) Successful in 4s
CI/CD / e2e-smoke (push) Has been skipped
CI/CD / test-frontend (push) Successful in 6s
CI/CD / test-runners (push) Has been skipped
CI/CD / test-go-pg (push) Successful in 2m48s
CI/CD / test-sqlite (push) Successful in 2m49s
CI/CD / build-and-deploy (push) Successful in 28s
Co-authored-by: Jeffrey Smith <jasafpro@gmail.com> Co-committed-by: Jeffrey Smith <jasafpro@gmail.com>
This commit was merged in pull request #61.
This commit is contained in:
34
server/store/api_token_iface.go
Normal file
34
server/store/api_token_iface.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package store
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"armature/models"
|
||||
)
|
||||
|
||||
// APITokenStore manages personal access tokens for programmatic API access.
|
||||
type APITokenStore interface {
|
||||
// Create inserts a new API token. The token_hash must be a SHA-256 hash
|
||||
// of the raw token string. ID and CreatedAt are set by the implementation.
|
||||
Create(ctx context.Context, token *models.APIToken) error
|
||||
|
||||
// GetByHash retrieves a non-expired token by its SHA-256 hash.
|
||||
// Returns nil, nil if not found or expired.
|
||||
GetByHash(ctx context.Context, tokenHash string) (*models.APIToken, error)
|
||||
|
||||
// ListForUser returns all tokens belonging to a user, ordered by created_at DESC.
|
||||
ListForUser(ctx context.Context, userID string) ([]models.APIToken, error)
|
||||
|
||||
// Revoke deletes a token owned by the specified user.
|
||||
// Returns the number of rows affected (0 if not found or not owned).
|
||||
Revoke(ctx context.Context, id, userID string) (int64, error)
|
||||
|
||||
// RevokeByID deletes a token by ID regardless of owner (admin use).
|
||||
RevokeByID(ctx context.Context, id string) (int64, error)
|
||||
|
||||
// CleanExpired deletes all tokens past their expires_at. Returns rows deleted.
|
||||
CleanExpired(ctx context.Context) (int64, error)
|
||||
|
||||
// UpdateLastUsed sets last_used_at to now for the given token ID.
|
||||
UpdateLastUsed(ctx context.Context, id string) error
|
||||
}
|
||||
Reference in New Issue
Block a user