Skip to content
This repository has been archived by the owner on Feb 7, 2020. It is now read-only.

Commit

Permalink
Merge pull request #3 from choria-io/69
Browse files Browse the repository at this point in the history
(#69) rename dependencies and remove need for choria/build
  • Loading branch information
ripienaar authored Jan 9, 2018
2 parents f7cde17 + 7ddd556 commit 72bc3ca
Show file tree
Hide file tree
Showing 12 changed files with 22 additions and 25 deletions.
7 changes: 1 addition & 6 deletions glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions protocol/protocol.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ const (
TransportV1 = "choria:transport:1"
)

// Secure controls the signing and validations of certificates in the protocol
var Secure = "true"

// IsSecure determines if this build will validate senders at protocol level
func IsSecure() bool {
return Secure == "true"
}

// Additional to these the package for a specific version must also provide these constructors
// with signature matching those in v1/constructors.go these are in use by mcollective/protocol.gos

Expand Down
5 changes: 2 additions & 3 deletions protocol/v1/constructors.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@ import (
"fmt"
"time"

"github.com/choria-io/go-choria/build"
"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
)

// NewRequest creates a choria:request:1
Expand Down Expand Up @@ -167,7 +166,7 @@ func NewSecureReplyFromTransport(message protocol.TransportMessage) (secure prot
func NewSecureRequest(request protocol.Request, publicCert string, privateCert string) (secure protocol.SecureRequest, err error) {
pubcerttxt := []byte("insecure")

if build.Secure == "true" {
if protocol.IsSecure() {
pubcerttxt, err = readFile(publicCert)
if err != nil {
err = fmt.Errorf("Could not read public certificate: %s", err.Error())
Expand Down
2 changes: 1 addition & 1 deletion protocol/v1/reply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1
import (
"time"

"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
"github.com/tidwall/gjson"

. "github.com/onsi/ginkgo"
Expand Down
2 changes: 1 addition & 1 deletion protocol/v1/request.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"sync"
"time"

"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
)

type request struct {
Expand Down
2 changes: 1 addition & 1 deletion protocol/v1/request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ package v1
import (
"time"

"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/tidwall/gjson"
Expand Down
2 changes: 1 addition & 1 deletion protocol/v1/security_reply.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
"strings"
"sync"

"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
)

// SecureReply contains 1 serialized Reply hashed
Expand Down
2 changes: 1 addition & 1 deletion protocol/v1/security_reply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import (
"crypto/sha256"
"encoding/base64"

"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
"github.com/tidwall/gjson"

. "github.com/onsi/ginkgo"
Expand Down
11 changes: 3 additions & 8 deletions protocol/v1/security_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,7 @@ import (
"strings"
"sync"

"github.com/choria-io/go-choria/build"
"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -55,7 +54,7 @@ func (r *secureRequest) SetMessage(request protocol.Request) (err error) {

r.Signature = "insecure"

if r.isSecure() {
if protocol.IsSecure() {
var signature []byte

signature, err = r.signString([]byte(j))
Expand All @@ -81,7 +80,7 @@ func (r *secureRequest) Valid() bool {
r.mu.Lock()
defer r.mu.Unlock()

if !r.isSecure() {
if !protocol.IsSecure() {
log.Debug("Bypassing validation on secure request due to build time flags")
return true
}
Expand Down Expand Up @@ -407,7 +406,3 @@ func readFile(path string) (cert []byte, err error) {

return
}

func (r *secureRequest) isSecure() bool {
return build.Secure == "true"
}
2 changes: 1 addition & 1 deletion protocol/v1/security_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ import (
"os"
"path/filepath"

"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/sirupsen/logrus"
Expand Down
2 changes: 1 addition & 1 deletion protocol/v1/transport.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
"strings"
"sync"

"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
)

type transportMessage struct {
Expand Down
2 changes: 1 addition & 1 deletion protocol/v1/transport_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
package v1

import (
"github.com/choria-io/go-choria/protocol"
"github.com/choria-io/go-protocol/protocol"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"github.com/tidwall/gjson"
Expand Down

0 comments on commit 72bc3ca

Please sign in to comment.