Skip to content
Snippets Groups Projects
Commit 0eda03e7 authored by Lyuben Penkovski's avatar Lyuben Penkovski
Browse files

Remove unnecessary Vault dependencies from vendor

The service doesn't use Vault client anymore as now
it asks the signer service for proofs.
Also golib is updated to the latest version.
parent 15184f73
No related branches found
No related tags found
1 merge request!3Use the signer service for adding VC and VP proofs
Pipeline #51497 failed with stage
in 27 seconds
Showing
with 4 additions and 72 deletions
......@@ -3,8 +3,7 @@ module code.vereign.com/gaiax/tsa/infohub
go 1.17
require (
code.vereign.com/gaiax/tsa/golib v0.0.0-20220603082703-12e9e3c06615
github.com/hashicorp/vault/api v1.6.0
code.vereign.com/gaiax/tsa/golib v0.0.0-20220615064316-ca49265d8b0e
github.com/hyperledger/aries-framework-go v0.1.8
github.com/kelseyhightower/envconfig v1.4.0
github.com/piprate/json-gold v0.4.1
......@@ -49,6 +48,7 @@ require (
github.com/hashicorp/go-version v1.2.0 // indirect
github.com/hashicorp/golang-lru v0.5.4 // indirect
github.com/hashicorp/hcl v1.0.0 // indirect
github.com/hashicorp/vault/api v1.6.0 // indirect
github.com/hashicorp/vault/sdk v0.5.0 // indirect
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d // indirect
github.com/hyperledger/aries-framework-go/spi v0.0.0-20220322085443-50e8f9bd208b // indirect
......
......@@ -38,6 +38,8 @@ cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RX
cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0=
code.vereign.com/gaiax/tsa/golib v0.0.0-20220603082703-12e9e3c06615 h1:EdWAZfrfEzWiIo0iMkCcs4bPTW7gItLLgJSU5I143vI=
code.vereign.com/gaiax/tsa/golib v0.0.0-20220603082703-12e9e3c06615/go.mod h1:bDorhOdL8/uRy56rvdBLWiRiOKlDjC5tQvpS5eN6wzo=
code.vereign.com/gaiax/tsa/golib v0.0.0-20220615064316-ca49265d8b0e h1:Tf+6cXb+hh/EsoNLyeGJ/T+hhJMn8Hdbo43cVkeAQZ4=
code.vereign.com/gaiax/tsa/golib v0.0.0-20220615064316-ca49265d8b0e/go.mod h1:bDorhOdL8/uRy56rvdBLWiRiOKlDjC5tQvpS5eN6wzo=
dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
......
package vault
import (
"context"
"encoding/base64"
"encoding/json"
"fmt"
"net/http"
vaultpkg "github.com/hashicorp/vault/api"
)
type Client struct {
keyname string
client *vaultpkg.Client
}
func New(addr string, token string, keyname string) (*Client, error) {
cfg := vaultpkg.DefaultConfig()
cfg.Address = addr
client, err := vaultpkg.NewClient(cfg)
if err != nil {
return nil, err
}
client.SetToken(token)
return &Client{
client: client,
keyname: keyname,
}, nil
}
func (c *Client) Sign(data []byte) ([]byte, error) {
body := map[string]interface{}{
"input": base64.StdEncoding.EncodeToString(data),
}
req := c.client.NewRequest(http.MethodPost, "/v1/transit/sign/"+c.keyname)
if err := req.SetJSONBody(body); err != nil {
return nil, err
}
// nolint:staticcheck
res, err := c.client.RawRequestWithContext(context.Background(), req)
if err != nil {
return nil, err
}
defer res.Body.Close()
if res.StatusCode != http.StatusOK {
return nil, fmt.Errorf("unexpected response from vault: %s", res.Status)
}
// expected response from the sign operation
var response struct {
Data struct {
Signature string `json:"signature"`
} `json:"data"`
}
if err := json.NewDecoder(res.Body).Decode(&response); err != nil {
return nil, err
}
if len(response.Data.Signature) == 0 {
return nil, fmt.Errorf("unexpected response: no signature")
}
return []byte(response.Data.Signature), nil
}
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
File suppressed by a .gitattributes entry or the file's encoding is unsupported.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment