2 * Copyright 2018 Intel Corporation, Inc
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
20 smsconfig "sms/config"
24 // SecretDomain is where Secrets are stored.
25 // A single domain can have any number of secrets
26 type SecretDomain struct {
27 UUID string `json:"uuid"`
28 Name string `json:"name"`
31 // Secret is the struct that defines the structure of a secret
32 // It consists of a name and map containing key value pairs
34 Name string `json:"name"`
35 Values map[string]interface{} `json:"values"`
38 // SecretBackend interface that will be implemented for various secret backends
39 type SecretBackend interface {
41 GetStatus() (bool, error)
42 Unseal(shard string) error
43 RegisterQuorum(pgpkey string) (string, error)
45 GetSecret(dom string, sec string) (Secret, error)
46 ListSecret(dom string) ([]string, error)
48 CreateSecretDomain(name string) (SecretDomain, error)
49 CreateSecret(dom string, sec Secret) error
51 DeleteSecretDomain(name string) error
52 DeleteSecret(dom string, name string) error
55 // InitSecretBackend returns an interface implementation
56 func InitSecretBackend() (SecretBackend, error) {
57 backendImpl := &Vault{
58 vaultAddress: smsconfig.SMSConfig.BackendAddress,
59 vaultToken: smsconfig.SMSConfig.VaultToken,
62 err := backendImpl.Init()
64 smslogger.WriteError(err.Error())
68 return backendImpl, nil
71 // LoginBackend Interface that will be implemented for various login backends
72 type LoginBackend interface {