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
2
Issue boards
Milestones
Wiki
Code
Merge requests
2
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
41159d80
Commit
41159d80
authored
6 years ago
by
Gospodin Bodurov
Browse files
Options
Downloads
Plain Diff
Merge branch '235-device_management' into 'master'
supported key suspend See merge request
!35
parents
3408af22
8edc7bea
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!35
supported key suspend
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
Gopkg.toml
+1
-5
1 addition, 5 deletions
Gopkg.toml
handler/revoke.go
+48
-16
48 additions, 16 deletions
handler/revoke.go
with
49 additions
and
21 deletions
Gopkg.toml
+
1
−
5
View file @
41159d80
[[constraint]]
branch
=
"
master
"
branch
=
"
added_key_suspend
"
name
=
"code.vereign.com/code/viam-apis"
[[constraint]]
name
=
"github.com/golang/protobuf"
version
=
"1.1.0"
[[constraint]]
name
=
"github.com/grpc-ecosystem/grpc-gateway"
version
=
"1.4.1"
[[constraint]]
branch
=
"master"
name
=
"golang.org/x/net"
...
...
This diff is collapsed.
Click to expand it.
handler/revoke.go
+
48
−
16
View file @
41159d80
...
...
@@ -27,40 +27,72 @@ import (
)
func
(
s
*
KeyStorageServerImpl
)
Revoke
(
ctx
context
.
Context
,
in
*
api
.
RevokeRequest
)
(
*
api
.
RevokeResponse
,
error
)
{
auth
:=
s
.
CreateAuthentication
(
ctx
)
client
:=
keyutils
.
CreateDataStorageClient
(
auth
)
defer
client
.
CloseClient
()
revokeResponse
:=
&
api
.
RevokeResponse
{}
revokeResponse
.
StatusList
=
revokeKey
(
client
,
in
.
Uuid
,
api
.
KeyType_PRIVATE
)
revokeResponse
.
StatusList
=
s
.
updateAll
(
ctx
,
in
.
Uuid
,
func
(
k
*
api
.
Key
)
{
k
.
Revoked
=
true
}
)
if
revokeResponse
.
StatusList
!=
nil
{
return
revokeResponse
,
nil
}
revokeResponse
.
StatusList
=
utils
.
AddStatus
(
revokeResponse
.
StatusList
,
"200"
,
api
.
StatusType_INFO
,
"Keys revoked"
)
return
revokeResponse
,
nil
}
revokeResponse
.
StatusList
=
revokeKey
(
client
,
in
.
Uuid
,
api
.
KeyType_PUBLIC
)
if
revokeResponse
.
StatusList
!=
nil
{
return
revokeResponse
,
nil
func
(
s
*
KeyStorageServerImpl
)
Suspend
(
ctx
context
.
Context
,
in
*
api
.
SuspendRequest
)
(
*
api
.
SuspendResponse
,
error
)
{
suspendResponse
:=
&
api
.
SuspendResponse
{}
suspendResponse
.
StatusList
=
s
.
updateAll
(
ctx
,
in
.
Uuid
,
func
(
k
*
api
.
Key
)
{
k
.
Suspended
=
true
})
if
suspendResponse
.
StatusList
!=
nil
{
return
suspendResponse
,
nil
}
suspendResponse
.
StatusList
=
utils
.
AddStatus
(
suspendResponse
.
StatusList
,
"200"
,
api
.
StatusType_INFO
,
"Keys suspended"
)
return
suspendResponse
,
nil
}
revokeResponse
.
StatusList
=
revokeKey
(
client
,
in
.
Uuid
,
api
.
KeyType_CERTIFICATE
)
if
revokeResponse
.
StatusList
!=
nil
{
return
revokeResponse
,
nil
func
(
s
*
KeyStorageServerImpl
)
Resume
(
ctx
context
.
Context
,
in
*
api
.
ResumeRequest
)
(
*
api
.
ResumeResponse
,
error
)
{
resumeResponse
:=
&
api
.
ResumeResponse
{}
resumeResponse
.
StatusList
=
s
.
updateAll
(
ctx
,
in
.
Uuid
,
func
(
k
*
api
.
Key
)
{
k
.
Suspended
=
false
})
if
resumeResponse
.
StatusList
!=
nil
{
return
resumeResponse
,
nil
}
resumeResponse
.
StatusList
=
utils
.
AddStatus
(
resumeResponse
.
StatusList
,
"200"
,
api
.
StatusType_INFO
,
"Keys resumed"
)
return
resumeResponse
,
nil
}
revokeResponse
.
StatusList
=
utils
.
AddStatus
(
revokeResponse
.
StatusList
,
"200"
,
api
.
StatusType_INFO
,
"Keys revoked"
)
return
revokeResponse
,
nil
func
(
s
*
KeyStorageServerImpl
)
Rename
(
ctx
context
.
Context
,
in
*
api
.
RenameRequest
)
(
*
api
.
RenameResponse
,
error
)
{
renameResponse
:=
&
api
.
RenameResponse
{}
renameResponse
.
StatusList
=
s
.
updateAll
(
ctx
,
in
.
Uuid
,
func
(
k
*
api
.
Key
)
{
k
.
Name
=
in
.
Name
})
if
renameResponse
.
StatusList
!=
nil
{
return
renameResponse
,
nil
}
renameResponse
.
StatusList
=
utils
.
AddStatus
(
renameResponse
.
StatusList
,
"200"
,
api
.
StatusType_INFO
,
"Keys renamed"
)
return
renameResponse
,
nil
}
func
revokeKey
(
client
*
client
.
DataStorageClientImpl
,
uuid
string
,
keyType
api
.
KeyType
)
[]
*
api
.
Status
{
func
(
s
*
KeyStorageServerImpl
)
updateAll
(
ctx
context
.
Context
,
uuid
string
,
update
func
(
*
api
.
Key
))
[]
*
api
.
Status
{
auth
:=
s
.
CreateAuthentication
(
ctx
)
client
:=
keyutils
.
CreateDataStorageClient
(
auth
)
defer
client
.
CloseClient
()
for
_
,
kType
:=
range
[]
api
.
KeyType
{
api
.
KeyType_PRIVATE
,
api
.
KeyType_PUBLIC
,
api
.
KeyType_CERTIFICATE
}
{
statusList
:=
updateKey
(
client
,
uuid
,
kType
,
update
)
if
statusList
!=
nil
{
return
statusList
}
}
return
nil
}
func
updateKey
(
client
*
client
.
DataStorageClientImpl
,
uuid
string
,
keyType
api
.
KeyType
,
update
func
(
*
api
.
Key
))
[]
*
api
.
Status
{
key
,
statusList
:=
keyutils
.
GetKey
(
client
,
uuid
,
keyType
)
if
statusList
!=
nil
{
return
statusList
}
key
.
Revoked
=
true
update
(
key
)
_
,
errors
,
err
:=
client
.
DoPutDataCall
(
"keys"
,
uuid
+
"/"
+
api
.
KeyType
.
String
(
keyType
),
key
,
versions
.
EntitiesManagementAgentApiVersion
)
statusList
=
keyutils
.
HandlePutDataErrors
(
statusList
,
errors
,
err
)
...
...
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