storj/storagenode/apikeys/apikeys.go
Egon Elbre 961e841bd7 all: fix error naming
errs.Class should not contain "error" in the name, since that causes a
lot of stutter in the error logs. As an example a log line could end up
looking like:

    ERROR node stats service error: satellitedbs error: node stats database error: no rows

Whereas something like:

    ERROR nodestats service: satellitedbs: nodestatsdb: no rows

Would contain all the necessary information without the stutter.

Change-Id: I7b7cb7e592ebab4bcfadc1eef11122584d2b20e0
2021-04-29 15:38:21 +03:00

39 lines
887 B
Go

// Copyright (C) 2020 Storj Labs, Inc.
// See LICENSE for copying information.
package apikeys
import (
"context"
"time"
"github.com/zeebo/errs"
"storj.io/storj/private/multinodeauth"
)
// ErrNoAPIKey represents no api key error.
var ErrNoAPIKey = errs.Class("no api key")
// DB is interface for working with api keys.
//
// architecture: Database
type DB interface {
// Store stores api key into db.
Store(ctx context.Context, apiKey APIKey) error
// Check checks if api key exists in db by secret.
Check(ctx context.Context, secret multinodeauth.Secret) error
// Revoke removes api key from db.
Revoke(ctx context.Context, secret multinodeauth.Secret) error
}
// APIKey describing api key in the database.
type APIKey struct {
// APIKeys is PK of the table and keeps unique value sno api key.
Secret multinodeauth.Secret
CreatedAt time.Time `json:"createdAt"`
}