Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
K
key-storage-agent
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Code
key-storage-agent
Commits
260de7e1
Commit
260de7e1
authored
5 years ago
by
Gospodin Bodurov
Browse files
Options
Downloads
Plain Diff
Merge branch 'smime-reflector' into 'master'
Smime reflector See merge request
!54
parents
63650b63
e5f71b24
Branches
Branches containing commit
Tags
1.0
1.0-rc1
Tags containing commit
1 merge request
!54
Smime reflector
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
config/configs.go
+6
-0
6 additions, 0 deletions
config/configs.go
handler/handler.go
+23
-18
23 additions, 18 deletions
handler/handler.go
with
29 additions
and
18 deletions
config/configs.go
+
6
−
0
View file @
260de7e1
...
@@ -25,6 +25,8 @@ var CaCertificatePEM []byte
...
@@ -25,6 +25,8 @@ var CaCertificatePEM []byte
var
VereignCaCertificatePEM
[]
byte
var
VereignCaCertificatePEM
[]
byte
var
VereignCaKeyPEM
[]
byte
var
VereignCaKeyPEM
[]
byte
var
ReplaceKey
bool
var
MaxMessageSize
int
var
MaxMessageSize
int
var
GrpcListenAddress
string
var
GrpcListenAddress
string
...
@@ -42,6 +44,8 @@ func SetConfigValues(configFile, etcdURL string) {
...
@@ -42,6 +44,8 @@ func SetConfigValues(configFile, etcdURL string) {
viper
.
SetDefault
(
"dataStorageUrl"
,
"data-storage-agent:7777"
)
viper
.
SetDefault
(
"dataStorageUrl"
,
"data-storage-agent:7777"
)
viper
.
SetDefault
(
"entitiesManagerUrl"
,
"entities-management-agent:7779"
)
viper
.
SetDefault
(
"entitiesManagerUrl"
,
"entities-management-agent:7779"
)
viper
.
SetDefault
(
"replaceKey"
,
false
)
viper
.
SetDefault
(
"viamUUID"
,
"viam-system"
)
viper
.
SetDefault
(
"viamUUID"
,
"viam-system"
)
viper
.
SetDefault
(
"viamSession"
,
"viam-session"
)
viper
.
SetDefault
(
"viamSession"
,
"viam-session"
)
...
@@ -127,6 +131,8 @@ func SetConfigValues(configFile, etcdURL string) {
...
@@ -127,6 +131,8 @@ func SetConfigValues(configFile, etcdURL string) {
DataStorageUrl
=
viper
.
GetString
(
"dataStorageUrl"
)
DataStorageUrl
=
viper
.
GetString
(
"dataStorageUrl"
)
EntitiesManagerUrl
=
viper
.
GetString
(
"entitiesManagerUrl"
)
EntitiesManagerUrl
=
viper
.
GetString
(
"entitiesManagerUrl"
)
ReplaceKey
=
viper
.
GetBool
(
"replaceKey"
)
SystemAuth
.
Uuid
=
viper
.
GetString
(
"viamUUID"
)
SystemAuth
.
Uuid
=
viper
.
GetString
(
"viamUUID"
)
SystemAuth
.
Session
=
viper
.
GetString
(
"viamSession"
)
SystemAuth
.
Session
=
viper
.
GetString
(
"viamSession"
)
...
...
This diff is collapsed.
Click to expand it.
handler/handler.go
+
23
−
18
View file @
260de7e1
...
@@ -22,8 +22,10 @@ import (
...
@@ -22,8 +22,10 @@ import (
"errors"
"errors"
"log"
"log"
"strings"
"strings"
"code.vereign.com/code/viam-apis/clientutils"
"code.vereign.com/code/viam-apis/clientutils"
"code.vereign.com/code/key-storage-agent/config"
keyutils
"code.vereign.com/code/key-storage-agent/utils"
keyutils
"code.vereign.com/code/key-storage-agent/utils"
"code.vereign.com/code/viam-apis/authentication"
"code.vereign.com/code/viam-apis/authentication"
"code.vereign.com/code/viam-apis/key-storage-agent/api"
"code.vereign.com/code/viam-apis/key-storage-agent/api"
...
@@ -94,7 +96,7 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
...
@@ -94,7 +96,7 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
if
in
.
KeyType
==
api
.
KeyType_KT_EMPTY
{
if
in
.
KeyType
==
api
.
KeyType_KT_EMPTY
{
getKeyResponse
.
StatusList
=
utils
.
AddStatus
(
getKeyResponse
.
StatusList
,
getKeyResponse
.
StatusList
=
utils
.
AddStatus
(
getKeyResponse
.
StatusList
,
"400"
,
api
.
StatusType_ERROR
,
"KeyType cannot be empty"
)
"400"
,
api
.
StatusType_ERROR
,
"KeyType cannot be empty"
)
return
getKeyResponse
,
nil
return
getKeyResponse
,
errors
.
New
(
"KeyType cannot be empty"
)
}
}
key
:=
&
api
.
Key
{}
key
:=
&
api
.
Key
{}
...
@@ -105,21 +107,22 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
...
@@ -105,21 +107,22 @@ func (s *KeyStorageServerImpl) GetKey(ctx context.Context, in *api.GetKeyRequest
getKeyResponse
.
Key
=
nil
getKeyResponse
.
Key
=
nil
getKeyResponse
.
StatusList
=
utils
.
AddStatus
(
getKeyResponse
.
StatusList
,
getKeyResponse
.
StatusList
=
utils
.
AddStatus
(
getKeyResponse
.
StatusList
,
"500"
,
api
.
StatusType_ERROR
,
err
.
Error
())
"500"
,
api
.
StatusType_ERROR
,
err
.
Error
())
return
getKeyResponse
,
nil
return
getKeyResponse
,
err
}
}
if
errorsString
!=
""
{
if
errorsString
!=
""
{
getKeyResponse
.
Key
=
nil
getKeyResponse
.
Key
=
nil
getKeyResponse
.
StatusList
=
utils
.
AddStatus
(
getKeyResponse
.
StatusList
,
getKeyResponse
.
StatusList
=
utils
.
AddStatus
(
getKeyResponse
.
StatusList
,
"500"
,
api
.
StatusType_ERROR
,
errorsString
)
"500"
,
api
.
StatusType_ERROR
,
errorsString
)
return
nil
,
errors
.
New
(
errorsString
)
}
}
if
!
hasData
{
if
!
hasData
{
log
.
Println
(
"No such key "
+
in
.
Uuid
)
log
.
Println
(
"No such key "
+
in
.
Uuid
)
getKeyResponse
.
Key
=
nil
getKeyResponse
.
Key
=
nil
getKeyResponse
.
StatusList
=
utils
.
AddStatus
(
getKeyResponse
.
StatusList
,
getKeyResponse
.
StatusList
=
utils
.
AddStatus
(
getKeyResponse
.
StatusList
,
"500"
,
api
.
StatusType_ERROR
,
err
.
Error
())
"500"
,
api
.
StatusType_ERROR
,
err
.
Error
())
return
getKeyResponse
,
nil
return
getKeyResponse
,
err
}
}
getKeyResponse
.
Key
=
key
getKeyResponse
.
Key
=
key
...
@@ -138,29 +141,31 @@ func (s *KeyStorageServerImpl) SetKey(ctx context.Context, in *api.SetKeyRequest
...
@@ -138,29 +141,31 @@ func (s *KeyStorageServerImpl) SetKey(ctx context.Context, in *api.SetKeyRequest
if
in
.
Uuid
==
"root"
{
if
in
.
Uuid
==
"root"
{
setKeyResponse
.
StatusList
=
utils
.
AddStatus
(
setKeyResponse
.
StatusList
,
setKeyResponse
.
StatusList
=
utils
.
AddStatus
(
setKeyResponse
.
StatusList
,
"400"
,
api
.
StatusType_ERROR
,
"Can not set root CA keys"
)
"400"
,
api
.
StatusType_ERROR
,
"Can not set root CA keys"
)
return
setKeyResponse
,
nil
return
setKeyResponse
,
errors
.
New
(
"Can not set root CA keys"
)
}
}
if
in
.
KeyType
==
api
.
KeyType_KT_EMPTY
{
if
in
.
KeyType
==
api
.
KeyType_KT_EMPTY
{
setKeyResponse
.
StatusList
=
utils
.
AddStatus
(
setKeyResponse
.
StatusList
,
setKeyResponse
.
StatusList
=
utils
.
AddStatus
(
setKeyResponse
.
StatusList
,
"400"
,
api
.
StatusType_ERROR
,
"KeyType cannot be empty"
)
"400"
,
api
.
StatusType_ERROR
,
"KeyType cannot be empty"
)
return
setKeyResponse
,
nil
return
setKeyResponse
,
errors
.
New
(
"KeyType cannot be empty"
)
}
}
key
:=
&
api
.
Key
{}
key
:=
&
api
.
Key
{}
_
,
_
,
err
:=
client
.
GetData
(
"keys"
,
in
.
Uuid
+
"/"
+
api
.
KeyType
.
String
(
in
.
KeyType
),
key
)
if
config
.
ReplaceKey
==
false
{
if
err
!=
nil
{
_
,
_
,
err
:=
client
.
GetData
(
"keys"
,
in
.
Uuid
+
"/"
+
api
.
KeyType
.
String
(
in
.
KeyType
),
key
)
log
.
Printf
(
"grpc call GetData to DataStorage failed: %s"
,
err
)
if
err
!=
nil
{
setKeyResponse
.
StatusList
=
utils
.
AddStatus
(
setKeyResponse
.
StatusList
,
log
.
Printf
(
"grpc call GetData to DataStorage failed: %s"
,
err
)
"500"
,
api
.
StatusType_ERROR
,
err
.
Error
())
setKeyResponse
.
StatusList
=
utils
.
AddStatus
(
setKeyResponse
.
StatusList
,
return
setKeyResponse
,
nil
"500"
,
api
.
StatusType_ERROR
,
err
.
Error
())
}
return
setKeyResponse
,
err
}
if
len
(
key
.
Content
)
>
0
{
if
len
(
key
.
Content
)
>
0
{
setKeyResponse
.
StatusList
=
utils
.
AddStatus
(
setKeyResponse
.
StatusList
,
setKeyResponse
.
StatusList
=
utils
.
AddStatus
(
setKeyResponse
.
StatusList
,
"400"
,
api
.
StatusType_ERROR
,
"Key is already set"
)
"400"
,
api
.
StatusType_ERROR
,
"Key is already set"
)
return
setKeyResponse
,
nil
return
setKeyResponse
,
errors
.
New
(
"Key is already set"
)
}
}
}
result
,
errors
,
err
:=
client
.
PutData
(
"keys"
,
in
.
Uuid
+
"/"
+
api
.
KeyType
.
String
(
in
.
KeyType
),
in
.
Key
)
result
,
errors
,
err
:=
client
.
PutData
(
"keys"
,
in
.
Uuid
+
"/"
+
api
.
KeyType
.
String
(
in
.
KeyType
),
in
.
Key
)
...
@@ -268,7 +273,7 @@ func (s *KeyStorageServerImpl) GetKeyId(ctx context.Context, in *api.GetKeyIdByK
...
@@ -268,7 +273,7 @@ func (s *KeyStorageServerImpl) GetKeyId(ctx context.Context, in *api.GetKeyIdByK
log
.
Printf
(
"Error: %s"
,
errorsString
)
log
.
Printf
(
"Error: %s"
,
errorsString
)
return
nil
,
errors
.
New
(
errorsString
)
return
nil
,
errors
.
New
(
errorsString
)
}
}
if
!
hasData
{
if
!
hasData
{
log
.
Println
(
"No such checkID "
+
checkID
)
log
.
Println
(
"No such checkID "
+
checkID
)
return
nil
,
errors
.
New
(
"No such checkID "
+
checkID
)
return
nil
,
errors
.
New
(
"No such checkID "
+
checkID
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment