Merge pull request #306 from openziti/support-identity-dial-bind

Support identity dial/bind
This commit is contained in:
Paul Lorenz
2020-09-29 09:34:17 -04:00
committed by GitHub
26 changed files with 682 additions and 271 deletions
+1 -7
View File
@@ -641,11 +641,6 @@ func (b *Broker) modelSessionToProto(ns *model.Session) (*edge_ctrl_pb.Session,
return nil, fmt.Errorf("could not convert to session proto, could not find service: %s", err)
}
apiSession, err := b.ae.Handlers.ApiSession.Read(ns.ApiSessionId)
if err != nil {
return nil, fmt.Errorf("could not convert to network session proto, could not find session: %s", err)
}
fps, err := b.getActiveFingerprints(ns.Id)
if err != nil {
@@ -664,9 +659,8 @@ func (b *Broker) modelSessionToProto(ns *model.Session) (*edge_ctrl_pb.Session,
}
return &edge_ctrl_pb.Session{
Id: apiSession.Id,
Id: ns.Id,
Token: ns.Token,
SessionToken: apiSession.Token,
Service: svc,
CertFingerprints: fps,
Type: sessionType,
+102
View File
@@ -0,0 +1,102 @@
package env
import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge/controller/persistence"
"github.com/openziti/fabric/controller/xtv"
nfpem "github.com/openziti/foundation/util/pem"
"github.com/openziti/sdk-golang/ziti/signing"
"github.com/pkg/errors"
"go.etcd.io/bbolt"
"strings"
"time"
)
func NewEdgeTerminatorValidator(ae *AppEnv) xtv.Validator {
return &EdgeTerminatorValidator{
ae: ae,
}
}
type EdgeTerminatorValidator struct {
ae *AppEnv
}
func (v *EdgeTerminatorValidator) Validate(tx *bbolt.Tx, terminator xtv.Terminator, create bool) error {
session, err := v.getTerminatorSession(tx, terminator, "")
if err != nil {
return err
}
if terminator.GetIdentity() == "" {
return nil
}
identityTerminators, err := v.ae.BoltStores.Terminator.GetTerminatorsInIdentityGroup(tx, terminator, create)
for _, otherTerminator := range identityTerminators {
otherSession, err := v.getTerminatorSession(tx, otherTerminator, "sibling ")
if err != nil {
return err
}
if otherSession != nil {
if otherSession.ApiSession.IdentityId != session.ApiSession.IdentityId {
return errors.Errorf("sibling terminator %v with shared identity %v belongs to different identity", terminator.GetId(), terminator.GetIdentity())
}
}
}
verifier, err := signing.GetVerifier(terminator.GetIdentitySecret())
if err != nil {
return err
}
now := time.Now()
certs, err := v.ae.BoltStores.Session.LoadCerts(tx, session.Id)
if err != nil {
return err
}
for _, cert := range certs {
if cert.ValidFrom.Before(now) && cert.ValidTo.After(now) {
for _, x509 := range nfpem.PemToX509(cert.Cert) {
if verifier.Verify(x509.PublicKey) {
pfxlog.Logger().Debugf("verified terminator %v with identity %v", terminator.GetId(), terminator.GetIdentity())
return nil
}
}
}
}
return errors.Errorf("unable to verify identity secret for identity %v", terminator.GetIdentity())
}
func (v *EdgeTerminatorValidator) getTerminatorSession(tx *bbolt.Tx, terminator xtv.Terminator, context string) (*persistence.Session, error) {
if terminator.GetBinding() != "edge" {
return nil, errors.Errorf("%vterminator %v with identity %v is not edge terminator. Can't share identity", context, terminator.GetId(), terminator.GetIdentity())
}
addressParts := strings.Split(terminator.GetAddress(), ":")
if len(addressParts) != 2 {
return nil, errors.Errorf("%vterminator %v with identity %v is not edge terminator. Can't share identity", context, terminator.GetId(), terminator.GetIdentity())
}
if addressParts[0] != "hosted" {
return nil, errors.Errorf("%vterminator %v with identity %v is not edge terminator. Can't share identity", context, terminator.GetId(), terminator.GetIdentity())
}
sessionToken := addressParts[1]
session, err := v.ae.BoltStores.Session.LoadOneByToken(tx, sessionToken)
if err != nil {
pfxlog.Logger().Warnf("sibling terminator %v with shared identity %v has invalid session token %v", terminator.GetId(), terminator.GetIdentity(), sessionToken)
return nil, nil
}
if session.ApiSession == nil {
apiSession, err := v.ae.BoltStores.ApiSession.LoadOneById(tx, session.ApiSessionId)
if err != nil {
return nil, err
}
session.ApiSession = apiSession
}
return session, nil
}
@@ -37,11 +37,13 @@ func MapCreateTerminatorToModel(terminator *rest_model.TerminatorCreate) *networ
BaseEntity: models.BaseEntity{
Tags: terminator.Tags,
},
Service: stringz.OrEmpty(terminator.Service),
Router: stringz.OrEmpty(terminator.Router),
Binding: terminator.Binding,
Address: stringz.OrEmpty(terminator.Address),
Precedence: xt.GetPrecedenceForName(string(terminator.Precedence)),
Service: stringz.OrEmpty(terminator.Service),
Router: stringz.OrEmpty(terminator.Router),
Binding: terminator.Binding,
Address: stringz.OrEmpty(terminator.Address),
Identity: terminator.Identity,
IdentitySecret: terminator.IdentitySecret,
Precedence: xt.GetPrecedenceForName(string(terminator.Precedence)),
}
if terminator.Cost != nil {
ret.Cost = uint16(*terminator.Cost)
@@ -126,6 +128,7 @@ func MapTerminatorToRestModel(ae *env.AppEnv, terminator *network.Terminator) (*
Router: ToEntityRef(router.Name, router, TransitRouterLinkFactory),
Binding: &terminator.Binding,
Address: &terminator.Address,
Identity: &terminator.Identity,
}
cost := rest_model.TerminatorCost(int64(terminator.Cost))
+6 -6
View File
@@ -92,22 +92,22 @@ func (entity *Session) toBoltEntityForCreate(tx *bbolt.Tx, handler Handler) (bol
return nil, err
}
fingerprints := map[string]bool{}
fingerprints := map[string]string{}
for _, authenticatorId := range identity.Authenticators {
authPrints, err := handler.GetEnv().GetHandlers().Authenticator.ReadFingerprints(authenticatorId)
authenticator, err := handler.GetEnv().GetStores().Authenticator.LoadOneById(tx, authenticatorId)
if err != nil {
pfxlog.Logger().Errorf("encountered error retrieving fingerprints for authenticator [%s]", authenticatorId)
continue
}
for _, fingerprint := range authPrints {
fingerprints[fingerprint] = true
if certAuth := authenticator.ToCert(); certAuth != nil {
fingerprints[certAuth.Fingerprint] = certAuth.Pem
}
}
for fingerprint := range fingerprints {
for fingerprint, cert := range fingerprints {
validFrom := time.Now()
validTo := time.Now().AddDate(1, 0, 0)
cert := "unknown"
boltEntity.Certs = append(boltEntity.Certs, &persistence.SessionCert{
Cert: cert,
@@ -17,6 +17,7 @@
package persistence
import (
"encoding/json"
"fmt"
"github.com/openziti/edge/eid"
"go.etcd.io/bbolt"
@@ -108,6 +109,22 @@ func (ctx *TestContext) testConfigCrud(*testing.T) {
ctx.RequireCreate(config)
ctx.ValidateBaseline(config)
configValue := `
{
"boolArr" : [true, false, false, true],
"numArr" : [1, 3, 4],
"strArr" : ["hello", "world", "how", "are", "you?"]
}
`
configMap := map[string]interface{}{}
err = json.Unmarshal([]byte(configValue), &configMap)
ctx.NoError(err)
config = newConfig(eid.New(), configType.Id, configMap)
ctx.RequireCreate(config)
ctx.ValidateBaseline(config)
config.Data = map[string]interface{}{
"dnsHostname": "ssh.mycompany.com",
"support": int64(22),
+8 -1
View File
@@ -19,10 +19,11 @@ package persistence
import (
"github.com/openziti/foundation/storage/boltz"
"github.com/pkg/errors"
log "github.com/sirupsen/logrus"
)
const (
CurrentDbVersion = 10
CurrentDbVersion = 11
FieldVersion = "version"
)
@@ -95,6 +96,12 @@ func (m *Migrations) migrate(step *boltz.MigrationStep) int {
}
}
if step.CurrentVersion < 11 {
step.SetError(m.stores.EdgeRouterPolicy.CheckIntegrity(step.Ctx.Tx(), true, func(err error, fixed bool) {
log.WithError(err).Debugf("attempting to update session token index. Fixed? %v", fixed)
}))
}
// current version
if step.CurrentVersion <= CurrentDbVersion {
return CurrentDbVersion
+17 -1
View File
@@ -130,7 +130,9 @@ func (entity *SessionCert) GetEntityType() string {
type SessionStore interface {
Store
LoadOneById(tx *bbolt.Tx, id string) (*Session, error)
LoadOneByToken(tx *bbolt.Tx, token string) (*Session, error)
LoadCerts(tx *bbolt.Tx, id string) ([]*SessionCert, error)
GetTokenIndex() boltz.ReadIndex
}
func newSessionStore(stores *stores) *sessionStoreImpl {
@@ -144,6 +146,7 @@ func newSessionStore(stores *stores) *sessionStoreImpl {
type sessionStoreImpl struct {
*baseStore
indexToken boltz.ReadIndex
symbolApiSession boltz.EntitySymbol
symbolService boltz.EntitySymbol
}
@@ -152,10 +155,15 @@ func (store *sessionStoreImpl) NewStoreEntity() boltz.Entity {
return &Session{}
}
func (store *sessionStoreImpl) GetTokenIndex() boltz.ReadIndex {
return store.indexToken
}
func (store *sessionStoreImpl) initializeLocal() {
store.AddExtEntitySymbols()
store.AddSymbol(FieldSessionToken, ast.NodeTypeString)
symbolToken := store.AddSymbol(FieldSessionToken, ast.NodeTypeString)
store.indexToken = store.AddUniqueIndex(symbolToken)
store.symbolApiSession = store.AddFkSymbol(FieldSessionApiSession, store.stores.apiSession)
store.symbolService = store.AddFkSymbol(FieldSessionService, store.stores.edgeService)
@@ -176,6 +184,14 @@ func (store *sessionStoreImpl) LoadOneById(tx *bbolt.Tx, id string) (*Session, e
return entity, nil
}
func (store *sessionStoreImpl) LoadOneByToken(tx *bbolt.Tx, token string) (*Session, error) {
id := store.indexToken.Read(tx, []byte(token))
if id != nil {
return store.LoadOneById(tx, string(id))
}
return nil, nil
}
func (store *sessionStoreImpl) LoadCerts(tx *bbolt.Tx, id string) ([]*SessionCert, error) {
ids := store.ListChildIds(tx, id, EntityTypeSessionCerts)
+6
View File
@@ -24,6 +24,7 @@ import (
"github.com/openziti/edge/controller/apierror"
"github.com/openziti/edge/controller/timeout"
"github.com/openziti/edge/rest_server"
"github.com/openziti/fabric/controller/xtv"
"net/http"
"os"
"os/signal"
@@ -197,6 +198,11 @@ func (c *Controller) Initialize() {
Errorf("could not add session enforcer")
}
xtv.RegisterValidator("edge", env.NewEdgeTerminatorValidator(c.AppEnv))
if err := xtv.InitializeMappings(); err != nil {
log.Fatalf("error initializing xtv: %+v", err)
}
}
func (c *Controller) Run() {
+9 -14
View File
@@ -53,7 +53,7 @@ type StateManager interface {
GetNetworkSession(token string) *edge_ctrl_pb.Session
GetNetworkSessionWithTimeout(token string, timeout time.Duration) *edge_ctrl_pb.Session
GetSessionByFingerprint(fingerprint string) chan *edge_ctrl_pb.ApiSession
GetSession(token string) chan *edge_ctrl_pb.ApiSession
GetSession(token string) *edge_ctrl_pb.ApiSession
AddNetworkSessionRemovedListener(token string, callBack func(token string)) RemoveListener
AddSessionRemovedListener(token string, callBack func(token string)) RemoveListener
StartHeartbeat(channel channel2.Channel, seconds int)
@@ -194,18 +194,13 @@ func (sm *StateManagerImpl) RemoveSession(token string) {
}
}
func (sm *StateManagerImpl) GetSession(token string) chan *edge_ctrl_pb.ApiSession {
ch := make(chan *edge_ctrl_pb.ApiSession)
go func() {
if val, ok := sm.sessionsByToken.Load(token); ok {
if session, ok := val.(*edge_ctrl_pb.ApiSession); ok {
ch <- session
return
}
func (sm *StateManagerImpl) GetSession(token string) *edge_ctrl_pb.ApiSession {
if val, ok := sm.sessionsByToken.Load(token); ok {
if session, ok := val.(*edge_ctrl_pb.ApiSession); ok {
return session
}
ch <- nil
}()
return ch
}
return nil
}
func (sm *StateManagerImpl) GetSessionByFingerprint(fingerprint string) chan *edge_ctrl_pb.ApiSession {
@@ -300,10 +295,10 @@ func (sm *StateManagerImpl) getSessionRemovedEventName(token string) events.Even
}
func (sm *StateManagerImpl) StartHeartbeat(ctrl channel2.Channel, intervalSeconds int) {
sm.heartbeatOperation = newHeartbeatOperation(ctrl, time.Duration(intervalSeconds) * time.Second, sm)
sm.heartbeatOperation = newHeartbeatOperation(ctrl, time.Duration(intervalSeconds)*time.Second, sm)
var err error
sm.heartbeatRunner, err = runner.NewRunner(1*time.Second, 24 * time.Hour, func(e error, operation runner.Operation) {
sm.heartbeatRunner, err = runner.NewRunner(1*time.Second, 24*time.Hour, func(e error, operation runner.Operation) {
pfxlog.Logger().WithError(err).Error("error during heartbeat runner")
})
+1 -9
View File
@@ -22,10 +22,8 @@ import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/edge/gateway/internal/fabric"
"github.com/openziti/edge/internal/cert"
"github.com/openziti/edge/pb/edge_ctrl_pb"
"github.com/openziti/foundation/channel2"
"github.com/openziti/sdk-golang/ziti/edge"
"time"
)
type sessionConnectionHandler struct {
@@ -51,13 +49,7 @@ func (handler *sessionConnectionHandler) BindChannel(ch channel2.Channel) error
fpg := cert.NewFingerprintGenerator()
fingerprints := fpg.FromCerts(certificates)
sessionCh := handler.stateManager.GetSession(token)
var session *edge_ctrl_pb.ApiSession
select {
case session = <-sessionCh:
case <-time.After(250 * time.Millisecond):
return errors.New("session token lookup timeout")
}
session := handler.stateManager.GetSession(token)
if session == nil {
_ = ch.Close()
+10 -2
View File
@@ -21,6 +21,7 @@ import (
"github.com/michaelquigley/pfxlog"
"github.com/openziti/fabric/controller/xt"
"github.com/openziti/fabric/router/xgress"
"github.com/openziti/foundation/channel2"
"github.com/openziti/foundation/identity/identity"
"github.com/openziti/sdk-golang/ziti/edge"
log "github.com/sirupsen/logrus"
@@ -77,11 +78,18 @@ func (dialer *dialer) Dial(destination string, sessionId *identity.TokenId, addr
return nil, fmt.Errorf("host for token '%v' not found", token)
}
callerId := ""
if sessionId.Data != nil {
if callerIdBytes, found := sessionId.Data[edge.CallerIdHeader]; found {
callerId = string(callerIdBytes)
}
}
log.Debug("dialing sdk client hosting service")
dialRequest := edge.NewDialMsg(listenConn.Id(), token)
dialRequest := edge.NewDialMsg(listenConn.Id(), token, callerId)
dialRequest.Headers[edge.PublicKeyHeader] = sessionId.Data[edge.PublicKeyHeader]
reply, err := listenConn.SendAndWaitWithTimeout(dialRequest, 5*time.Second)
reply, err := listenConn.SendPrioritizedAndWaitWithTimeout(dialRequest, channel2.Highest, 5*time.Second)
if err != nil {
return nil, err
}
+16 -2
View File
@@ -152,6 +152,10 @@ func (proxy *ingressProxy) processConnect(req *channel2.Message, ch channel2.Cha
peerData := make(map[uint32][]byte)
peerData[edge.PublicKeyHeader] = req.Headers[edge.PublicKeyHeader]
if callerId, found := req.Headers[edge.CallerIdHeader]; found {
peerData[edge.CallerIdHeader] = callerId
}
if ns.Service.EncryptionRequired && req.Headers[edge.PublicKeyHeader] == nil {
msg := "encryption required on service, initiator did not send public header"
proxy.sendStateClosedReply(msg, req)
@@ -159,7 +163,11 @@ func (proxy *ingressProxy) processConnect(req *channel2.Message, ch channel2.Cha
return
}
sessionInfo, err := xgress.GetSession(proxy.listener.factory, ns.Id, ns.Service.Id, peerData)
service := ns.Service.Id
if terminatorIdentity, found := req.GetStringHeader(edge.TerminatorIdentityHeader); found {
service = terminatorIdentity + "@" + service
}
sessionInfo, err := xgress.GetSession(proxy.listener.factory, ns.Id, service, peerData)
if err != nil {
log.Warn("failed to dial fabric ", err)
proxy.sendStateClosedReply(err.Error(), req)
@@ -270,7 +278,13 @@ func (proxy *ingressProxy) processBind(req *channel2.Message, ch channel2.Channe
proxy.listener.factory.hostedServices.Put(token, messageSink)
terminatorId, err := xgress.AddTerminator(proxy.listener.factory, ns.Service.Id, "edge", "hosted:"+token, hostData, cost, precedence)
terminatorIdentity, _ := req.GetStringHeader(edge.TerminatorIdentityHeader)
var terminatorIdentitySecret []byte
if terminatorIdentity != "" {
terminatorIdentitySecret, _ = req.Headers[edge.TerminatorIdentitySecretHeader]
}
terminatorId, err := xgress.AddTerminator(proxy.listener.factory, ns.Service.Id, "edge", "hosted:"+token, terminatorIdentity, terminatorIdentitySecret, hostData, cost, precedence)
messageSink.terminatorIdRef.Set(terminatorId)
log.Debugf("registered listener for terminator %v, token: %v", terminatorId, token)
+2 -3
View File
@@ -32,12 +32,11 @@ require (
github.com/miekg/dns v1.1.31
github.com/mitchellh/mapstructure v1.3.3
github.com/netfoundry/secretstream v0.1.2
github.com/openziti/fabric v0.13.6
github.com/openziti/fabric v0.14.2
github.com/openziti/foundation v0.14.5
github.com/openziti/sdk-golang v0.13.46
github.com/openziti/sdk-golang v0.13.47
github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6
github.com/pkg/errors v0.9.1
github.com/rcrowley/go-metrics v0.0.0-20200313005456-10cdbea86bc0
github.com/sirupsen/logrus v1.6.0
github.com/spf13/cobra v1.0.0
github.com/stretchr/testify v1.6.1
+4 -6
View File
@@ -373,14 +373,12 @@ github.com/onsi/gomega v1.8.1/go.mod h1:Ho0h+IUsWyvy1OpqCwxlQ/21gkhVunqlU8fDGcoT
github.com/onsi/gomega v1.10.1 h1:o0+MgICZLuZ7xjH7Vx6zS/zcu93/BEp1VwkIW1mEXCE=
github.com/onsi/gomega v1.10.1/go.mod h1:iN09h71vgCQne3DLsj+A5owkum+a2tYe+TOCB1ybHNo=
github.com/openzipkin/zipkin-go v0.1.1/go.mod h1:NtoC/o8u3JlF1lSlyPNswIbeQH9bJTmOf0Erfk+hxe8=
github.com/openziti/fabric v0.13.6 h1:z3ULb1BdhSAEEp6aSwcxAY0B0QOVZM0LOuDqHRo9Ugg=
github.com/openziti/fabric v0.13.6/go.mod h1:nCUaSeDlpvmgWzFlizIDMJBy/ynLg/oLKj7PVjPx1i0=
github.com/openziti/foundation v0.14.4 h1:03eMJT1XFU71+hj1tzdetZPQw1+SiMpXtz/Q97rBT/Y=
github.com/openziti/foundation v0.14.4/go.mod h1:BxcI+GProVBiFYRDkrjg+/r5ptd8/iYdsc+bxAxwQCk=
github.com/openziti/fabric v0.14.2 h1:G+/iquSwMJBEtDDJQhYhdRysvnl/u82X+/Kqk3hC0sE=
github.com/openziti/fabric v0.14.2/go.mod h1:xlES2jGDEuvDGMXvAugWVDhbZdx8dTw6jZBeX1s52Wc=
github.com/openziti/foundation v0.14.5 h1:GifwpaJz1jqkHN65spQQATnLVr2B/JYrBSaGCxenMZM=
github.com/openziti/foundation v0.14.5/go.mod h1:BxcI+GProVBiFYRDkrjg+/r5ptd8/iYdsc+bxAxwQCk=
github.com/openziti/sdk-golang v0.13.46 h1:z7kzh5v1UQtO1tZM/79RnNhvfJt0tT3NMA/MWFBR1lc=
github.com/openziti/sdk-golang v0.13.46/go.mod h1:Xxz3Gxnms/NvdTQR8ltoui4AHSXX8JqABOkO5OdL/74=
github.com/openziti/sdk-golang v0.13.47 h1:VsrOv9nTQWGdS89hKG8LSQvWzJFWZtNtBT+o4ULYP70=
github.com/openziti/sdk-golang v0.13.47/go.mod h1:Xxz3Gxnms/NvdTQR8ltoui4AHSXX8JqABOkO5OdL/74=
github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6 h1:lNCW6THrCKBiJBpz8kbVGjC7MgdCGKwuvBgc7LoD6sw=
github.com/orcaman/concurrent-map v0.0.0-20190826125027-8c72a8bb44f6/go.mod h1:Lu3tH6HLW3feq74c2GC+jIMS/K2CFcDWnWD9XkenwhI=
github.com/pborman/uuid v1.2.0/go.mod h1:X/NO0urCmaxf9VXbdlT7C2Yzkj2IKimNn4k+gtPdI/k=
+45 -54
View File
@@ -329,7 +329,6 @@ type Session struct {
CertFingerprints []string `protobuf:"bytes,3,rep,name=certFingerprints,proto3" json:"certFingerprints,omitempty"`
Urls []string `protobuf:"bytes,4,rep,name=urls,proto3" json:"urls,omitempty"`
Service *Service `protobuf:"bytes,5,opt,name=service,proto3" json:"service,omitempty"`
SessionToken string `protobuf:"bytes,6,opt,name=sessionToken,proto3" json:"sessionToken,omitempty"`
Id string `protobuf:"bytes,7,opt,name=id,proto3" json:"id,omitempty"`
XXX_NoUnkeyedLiteral struct{} `json:"-"`
XXX_unrecognized []byte `json:"-"`
@@ -396,13 +395,6 @@ func (m *Session) GetService() *Service {
return nil
}
func (m *Session) GetSessionToken() string {
if m != nil {
return m.SessionToken
}
return ""
}
func (m *Session) GetId() string {
if m != nil {
return m.Id
@@ -787,50 +779,49 @@ func init() {
}
var fileDescriptor_23f46a161f139ee1 = []byte{
// 719 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0xac, 0x55, 0xcd, 0x6e, 0xd3, 0x4c,
0x14, 0xed, 0x38, 0x49, 0x93, 0xdc, 0x54, 0x8d, 0xbf, 0xfb, 0x35, 0xc5, 0x2d, 0x20, 0x05, 0xb3,
0x89, 0x8a, 0x1a, 0x44, 0x59, 0x14, 0x75, 0x57, 0xfa, 0xa3, 0x4a, 0x48, 0x20, 0xb9, 0xb0, 0x41,
0x42, 0xc8, 0xb5, 0xaf, 0x8a, 0x55, 0xd7, 0x13, 0x66, 0x26, 0x91, 0xb2, 0x07, 0xde, 0x01, 0xa9,
0xa9, 0x80, 0x17, 0xe1, 0x05, 0x60, 0xc5, 0x4b, 0xf0, 0xb3, 0xe4, 0x05, 0x90, 0xc7, 0x76, 0xe2,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75, 0x2e, 0x68, 0xba,
0xf9, 0xed, 0x6c, 0x33, 0x4f, 0xfa, 0x7d, 0xc4, 0xf0, 0x3a, 0x5c, 0x29, 0x08, 0x89, 0x6e, 0xff,
0x18, 0x31, 0x34, 0x01, 0x76, 0x22, 0xc1, 0xc3, 0x50, 0x23, 0x9f, 0x4e, 0xb5, 0xf2, 0x04, 0xd9,
0x22, 0xa1, 0xa4, 0x86, 0x3f, 0x9f, 0xb2, 0x95, 0x1b, 0xf1, 0xdf, 0xd7, 0xf8, 0x95, 0x89, 0x0d,
0xdc, 0x0e, 0xdc, 0xd0, 0x9c, 0x89, 0x57, 0xf7, 0x83, 0xc8, 0x37, 0xd9, 0xc1, 0xac, 0x7e, 0xed,
0xef, 0xfe, 0x0a, 0x00, 0x00, 0xff, 0xff, 0xbb, 0x38, 0x54, 0xdd, 0x0a, 0x07, 0x00, 0x00,
// 700 bytes of a gzipped FileDescriptorProto
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x09, 0x6e, 0x88, 0x02, 0xff, 0xac, 0x55, 0xdd, 0x6e, 0xd3, 0x4c,
0x10, 0xfd, 0x9c, 0xa4, 0x4d, 0x32, 0xa9, 0x1a, 0x7f, 0x0b, 0x29, 0x69, 0x01, 0xa9, 0x98, 0x9b,
0xaa, 0xa8, 0x41, 0x94, 0x8b, 0xa2, 0xde, 0x95, 0xfe, 0xa8, 0x12, 0x12, 0x48, 0x2e, 0xdc, 0x20,
0x21, 0xe4, 0xda, 0xab, 0x62, 0xd5, 0xf5, 0x86, 0xf5, 0xa6, 0x52, 0xee, 0x81, 0x77, 0x40, 0x82,
0x0a, 0x78, 0x11, 0x5e, 0x00, 0xc4, 0x05, 0x2f, 0xc1, 0xcf, 0x4b, 0x30, 0x3b, 0xfe, 0xc9, 0xa6,
0x31, 0xd0, 0x4a, 0xdc, 0xed, 0x9e, 0x33, 0x7b, 0x76, 0xe6, 0xec, 0x78, 0x0c, 0x6d, 0x1e, 0x1c,
0xf0, 0xa7, 0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xa1, 0xca, 0x53, 0x64, 0x13, 0x3f, 0xaf,
0x84, 0xe0, 0xcf, 0x27, 0xd6, 0xf2, 0x35, 0xfd, 0x6b, 0x2a, 0x26, 0x88, 0x36, 0x70, 0x2b, 0xf4,
0x22, 0x34, 0x10, 0x57, 0x77, 0xc3, 0x38, 0xb0, 0xad, 0xfd, 0x69, 0x9a, 0xe4, 0xb7, 0x7f, 0x05,
0x00, 0x00, 0xff, 0xff, 0xe5, 0xef, 0x7d, 0x75, 0xe6, 0x06, 0x00, 0x00,
}
-1
View File
@@ -53,7 +53,6 @@ message Session {
repeated string certFingerprints = 3;
repeated string urls = 4;
Service service = 5;
string sessionToken = 6;
string id = 7;
}
+7
View File
@@ -51,6 +51,13 @@ type TerminatorCreate struct {
// cost
Cost *TerminatorCost `json:"cost,omitempty"`
// identity
Identity string `json:"identity,omitempty"`
// identity secret
// Format: byte
IdentitySecret strfmt.Base64 `json:"identitySecret,omitempty"`
// precedence
Precedence TerminatorPrecedence `json:"precedence,omitempty"`
+25
View File
@@ -58,6 +58,10 @@ type TerminatorDetail struct {
// Required: true
DynamicCost *TerminatorCost `json:"dynamicCost"`
// identity
// Required: true
Identity *string `json:"identity"`
// precedence
// Required: true
Precedence TerminatorPrecedence `json:"precedence"`
@@ -98,6 +102,8 @@ func (m *TerminatorDetail) UnmarshalJSON(raw []byte) error {
DynamicCost *TerminatorCost `json:"dynamicCost"`
Identity *string `json:"identity"`
Precedence TerminatorPrecedence `json:"precedence"`
Router *EntityRef `json:"router"`
@@ -120,6 +126,8 @@ func (m *TerminatorDetail) UnmarshalJSON(raw []byte) error {
m.DynamicCost = dataAO1.DynamicCost
m.Identity = dataAO1.Identity
m.Precedence = dataAO1.Precedence
m.Router = dataAO1.Router
@@ -151,6 +159,8 @@ func (m TerminatorDetail) MarshalJSON() ([]byte, error) {
DynamicCost *TerminatorCost `json:"dynamicCost"`
Identity *string `json:"identity"`
Precedence TerminatorPrecedence `json:"precedence"`
Router *EntityRef `json:"router"`
@@ -170,6 +180,8 @@ func (m TerminatorDetail) MarshalJSON() ([]byte, error) {
dataAO1.DynamicCost = m.DynamicCost
dataAO1.Identity = m.Identity
dataAO1.Precedence = m.Precedence
dataAO1.Router = m.Router
@@ -213,6 +225,10 @@ func (m *TerminatorDetail) Validate(formats strfmt.Registry) error {
res = append(res, err)
}
if err := m.validateIdentity(formats); err != nil {
res = append(res, err)
}
if err := m.validatePrecedence(formats); err != nil {
res = append(res, err)
}
@@ -293,6 +309,15 @@ func (m *TerminatorDetail) validateDynamicCost(formats strfmt.Registry) error {
return nil
}
func (m *TerminatorDetail) validateIdentity(formats strfmt.Registry) error {
if err := validate.Required("identity", "body", m.Identity); err != nil {
return err
}
return nil
}
func (m *TerminatorDetail) validatePrecedence(formats strfmt.Registry) error {
if err := m.Precedence.Validate(formats); err != nil {
+22
View File
@@ -7550,6 +7550,13 @@ func init() {
"cost": {
"$ref": "#/definitions/terminatorCost"
},
"identity": {
"type": "string"
},
"identitySecret": {
"type": "string",
"format": "byte"
},
"precedence": {
"$ref": "#/definitions/terminatorPrecedence"
},
@@ -7579,6 +7586,7 @@ func init() {
"router",
"binding",
"address",
"identity",
"cost",
"precedence",
"dynamicCost"
@@ -7596,6 +7604,9 @@ func init() {
"dynamicCost": {
"$ref": "#/definitions/terminatorCost"
},
"identity": {
"type": "string"
},
"precedence": {
"$ref": "#/definitions/terminatorPrecedence"
},
@@ -23353,6 +23364,13 @@ func init() {
"cost": {
"$ref": "#/definitions/terminatorCost"
},
"identity": {
"type": "string"
},
"identitySecret": {
"type": "string",
"format": "byte"
},
"precedence": {
"$ref": "#/definitions/terminatorPrecedence"
},
@@ -23382,6 +23400,7 @@ func init() {
"router",
"binding",
"address",
"identity",
"cost",
"precedence",
"dynamicCost"
@@ -23399,6 +23418,9 @@ func init() {
"dynamicCost": {
"$ref": "#/definitions/terminatorCost"
},
"identity": {
"type": "string"
},
"precedence": {
"$ref": "#/definitions/terminatorPrecedence"
},
+156 -148
View File
File diff suppressed because it is too large Load Diff
+202
View File
@@ -0,0 +1,202 @@
// +build apitests
/*
Copyright NetFoundry, Inc.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
https://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
package tests
import (
"fmt"
"github.com/openziti/fabric/controller/xt_smartrouting"
"github.com/openziti/sdk-golang/ziti"
"github.com/openziti/sdk-golang/ziti/edge"
"github.com/pkg/errors"
"net"
"testing"
"time"
)
func Test_AddressableTerminators(t *testing.T) {
ctx := NewTestContext(t)
defer ctx.Teardown()
ctx.StartServer()
ctx.RequireAdminLogin()
service := ctx.AdminSession.RequireNewServiceAccessibleToAll(xt_smartrouting.Name)
fmt.Printf("service id: %v\n", service.Id)
ctx.CreateEnrollAndStartEdgeRouter()
type host struct {
id *identity
context ziti.Context
listener net.Listener
}
var hosts []*host
var err error
for i := 0; i < 2; i++ {
host := &host{}
hosts = append(hosts, host)
host.id, host.context = ctx.AdminSession.RequireCreateSdkContext()
host.listener, err = host.context.ListenWithOptions(service.Name, &ziti.ListenOptions{
BindUsingEdgeIdentity: true,
})
ctx.Req.NoError(err)
}
type client struct {
id *identity
context ziti.Context
}
var clients []*client
for i := 0; i < 3; i++ {
client := &client{}
clients = append(clients, client)
client.id, client.context = ctx.AdminSession.RequireCreateSdkContext()
}
waitForConn := func(listener net.Listener, timeout time.Duration) (net.Conn, error) {
connC := make(chan net.Conn, 1)
errC := make(chan error, 1)
go func() {
conn, err := listener.Accept()
if err != nil {
errC <- err
} else {
connC <- conn
}
}()
select {
case conn := <-connC:
return conn, nil
case err := <-errC:
return nil, err
case <-time.After(timeout):
return nil, errors.Errorf("timed out waiting for connection after %v", timeout)
}
}
for _, client := range clients {
for _, host := range hosts {
conn, err := client.context.DialWithOptions(service.Name, &ziti.DialOptions{
Identity: host.id.name,
})
ctx.Req.NoError(err)
hostConn, err := waitForConn(host.listener, time.Second)
ctx.Req.NoError(err)
ctx.Req.Equal(client.id.name, hostConn.RemoteAddr().String())
ctx.Req.NoError(conn.Close())
ctx.Req.NoError(hostConn.Close())
}
}
}
func Test_AddressableTerminatorSameIdentity(t *testing.T) {
ctx := NewTestContext(t)
defer ctx.Teardown()
ctx.StartServer()
ctx.RequireAdminLogin()
service := ctx.AdminSession.RequireNewServiceAccessibleToAll(xt_smartrouting.Name)
fmt.Printf("service id: %v\n", service.Id)
ctx.CreateEnrollAndStartEdgeRouter()
errorC := make(chan error, 1)
errorHandler := func(err error) {
select {
case errorC <- err:
default:
}
}
identity, context := ctx.AdminSession.RequireCreateSdkContext()
listener, err := context.ListenWithOptions(service.Name, &ziti.ListenOptions{
BindUsingEdgeIdentity: true,
ConnectTimeout: 5 * time.Second,
})
ctx.Req.NoError(err)
listener.(edge.SessionListener).SetErrorEventHandler(errorHandler)
defer func() { _ = listener.Close() }()
context2 := ziti.NewContextWithConfig(identity.config)
listener2, err := context2.ListenWithOptions(service.Name, &ziti.ListenOptions{
BindUsingEdgeIdentity: true,
ConnectTimeout: 5 * time.Second,
})
listener2.(edge.SessionListener).SetErrorEventHandler(errorHandler)
ctx.Req.NoError(err)
defer func() { _ = listener2.Close() }()
select {
case err = <-errorC:
case <-time.After(5 * time.Second):
err = nil
}
ctx.Req.NoError(err)
}
func Test_AddressableTerminatorDifferentIdentity(t *testing.T) {
ctx := NewTestContext(t)
defer ctx.Teardown()
ctx.StartServer()
ctx.RequireAdminLogin()
service := ctx.AdminSession.RequireNewServiceAccessibleToAll(xt_smartrouting.Name)
fmt.Printf("service id: %v\n", service.Id)
ctx.CreateEnrollAndStartEdgeRouter()
errorC := make(chan error, 1)
errorHandler := func(err error) {
select {
case errorC <- err:
default:
}
}
_, context := ctx.AdminSession.RequireCreateSdkContext()
listener, err := context.ListenWithOptions(service.Name, &ziti.ListenOptions{
Identity: "foobar",
ConnectTimeout: 5 * time.Second,
})
listener.(edge.SessionListener).SetErrorEventHandler(errorHandler)
ctx.Req.NoError(err)
defer func() { _ = listener.Close() }()
_, context2 := ctx.AdminSession.RequireCreateSdkContext()
listener2, err := context2.ListenWithOptions(service.Name, &ziti.ListenOptions{
Identity: "foobar",
ConnectTimeout: 5 * time.Second,
})
ctx.Req.NoError(err)
listener2.(edge.SessionListener).SetErrorEventHandler(errorHandler)
defer func() { _ = listener2.Close() }()
select {
case err = <-errorC:
case <-time.After(5 * time.Second):
err = nil
}
ctx.Req.Error(err)
ctx.Req.Contains(err.Error(), "shared identity foobar belongs to different identity")
}
+12 -8
View File
@@ -7,19 +7,23 @@ v: 3
# memory:
# path: ctrl.memprof
db: testdata/${ZITI_TEST_DB}.db
db: testdata/${ZITI_TEST_DB}.db
identity:
cert: testdata/ca/intermediate/certs/ctrl-client.cert.pem
server_cert: testdata/ca/intermediate/certs/ctrl-server.cert.pem
key: testdata/ca/intermediate/private/ctrl.key.pem
ca: testdata/ca/intermediate/certs/ca-chain.cert.pem
cert: testdata/ca/intermediate/certs/ctrl-client.cert.pem
server_cert: testdata/ca/intermediate/certs/ctrl-server.cert.pem
key: testdata/ca/intermediate/private/ctrl.key.pem
ca: testdata/ca/intermediate/certs/ca-chain.cert.pem
ctrl:
listener: tls:127.0.0.1:6262
listener: tls:127.0.0.1:6262
mgmt:
listener: tls:127.0.0.1:10000
listener: tls:127.0.0.1:10000
terminator:
validators:
edge: edge
#metrics:
# influxdb:
@@ -38,7 +42,7 @@ edge:
# This section represents the configuration of the Edge API that is served over HTTPS
api:
# (required) The interface and port that the Edge API should be served on.
listener: 127.0.0.1:1281
listener: 127.0.0.1:1281
# (required) The host/port combination that is reported as publicly accessible for the Edge API
advertise: localhost:1281
# (optional, defaults to 10) The number of minutes before an Edge API session will timeout. Timeouts are reset by
+1 -1
View File
@@ -1,4 +1,4 @@
// +build apitests,perftests
// +build apitests,perftests,ignore
/*
Copyright NetFoundry, Inc.
+2 -2
View File
@@ -231,8 +231,8 @@ func (request *authenticatedRequests) newAuthenticatedJsonRequest(body interface
func (request *authenticatedRequests) RequireCreateSdkContext() (*identity, ziti.Context) {
identity := request.RequireNewIdentityWithOtt(false)
config := request.testContext.EnrollIdentity(identity.Id)
context := ziti.NewContextWithConfig(config)
identity.config = request.testContext.EnrollIdentity(identity.Id)
context := ziti.NewContextWithConfig(identity.config)
return identity, context
}
+2
View File
@@ -28,6 +28,7 @@ import (
"crypto/x509/pkix"
"encoding/pem"
"github.com/openziti/edge/eid"
"github.com/openziti/sdk-golang/ziti/config"
"math/big"
"sort"
"time"
@@ -157,6 +158,7 @@ type identity struct {
enrollment map[string]interface{}
roleAttributes []string
tags map[string]interface{}
config *config.Config
}
func (entity *identity) getId() string {
+1 -1
View File
@@ -1,4 +1,4 @@
// +build apitests,perftests
// +build apitests,perftests,ignore
package tests