-
Notifications
You must be signed in to change notification settings - Fork 402
/
apikeys.go
38 lines (28 loc) · 887 Bytes
/
apikeys.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
// 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"`
}