prysm-pulse/validator/db/kv/web_api.go
Raul Jordan 16c34b627f
Add Authentication Functions to Validator RPC (#6968)
* define auth endpoints
* add intercepter with tests
* auth functions
* fix up the auth functions
* add functions for storing and saving the hashed password from the validator db
* validate strong password input and simplify jwt claims
* tests for db funcs
* comments for db funcs
* wrap up the authentication tests
* register auth srv
* use proper db iface package and check if existing password
* fix broken tests and add new test to check if password already exists
* use roughtime
* rlock to check the auth paths
* Merge refs/heads/master into auth-rpc
* Merge refs/heads/master into auth-rpc
* Merge refs/heads/master into auth-rpc
* leave out the stream interceptor
* resolve confs
* Merge branch 'master' into auth-rpc
* confs
* Merge branch 'auth-rpc' of github.com:prysmaticlabs/prysm into auth-rpc
* Merge refs/heads/master into auth-rpc
* Merge refs/heads/master into auth-rpc
* Merge refs/heads/master into auth-rpc
* Merge refs/heads/master into auth-rpc
2020-08-13 20:27:42 +00:00

30 lines
838 B
Go

package kv
import (
"context"
bolt "go.etcd.io/bbolt"
)
// SaveHashedPasswordForAPI stores a hashed password used
// in API authentication for the validator client.
func (store *Store) SaveHashedPasswordForAPI(ctx context.Context, hashedPassword []byte) error {
return store.update(func(tx *bolt.Tx) error {
bucket := tx.Bucket(validatorAPIBucket)
return bucket.Put(apiHashedPasswordKey, hashedPassword)
})
}
// HashedPasswordForAPI retrieves the hashed password used
// in API authentication for the validator client.
func (store *Store) HashedPasswordForAPI(ctx context.Context) ([]byte, error) {
var err error
var hashedPassword []byte
err = store.view(func(tx *bolt.Tx) error {
bucket := tx.Bucket(validatorAPIBucket)
hashedPassword = bucket.Get(apiHashedPasswordKey)
return nil
})
return hashedPassword, err
}