diff --git a/vendor/github.com/nats-io/jwt/exports.go b/vendor/github.com/nats-io/jwt/exports.go index b27f1808aa..4e4e09157f 100644 --- a/vendor/github.com/nats-io/jwt/exports.go +++ b/vendor/github.com/nats-io/jwt/exports.go @@ -45,14 +45,7 @@ func (e *Exports) Add(i ...*Export) { *e = append(*e, i...) } -// Validate calls validate on all of the exports -func (e *Exports) Validate(vr *ValidationResults) error { - var subjects []Subject - for _, v := range *e { - subjects = append(subjects, v.Subject) - v.Validate(vr) - } - // collect all the subjects, and validate that no subject is a subset +func isContainedIn(kind ExportType, subjects []Subject, vr *ValidationResults) { m := make(map[string]string) for i, ns := range subjects { for j, s := range subjects { @@ -73,10 +66,28 @@ func (e *Exports) Validate(vr *ValidationResults) error { for k, v := range m { var vi ValidationIssue vi.Blocking = true - vi.Description = fmt.Sprintf("export subject %q already exports %q", k, v) + vi.Description = fmt.Sprintf("%s export subject %q already exports %q", kind, k, v) vr.Add(&vi) } } +} + +// Validate calls validate on all of the exports +func (e *Exports) Validate(vr *ValidationResults) error { + var serviceSubjects []Subject + var streamSubjects []Subject + + for _, v := range *e { + if v.IsService() { + serviceSubjects = append(serviceSubjects, v.Subject) + } else { + streamSubjects = append(streamSubjects, v.Subject) + } + v.Validate(vr) + } + + isContainedIn(Service, serviceSubjects, vr) + isContainedIn(Stream, streamSubjects, vr) return nil } diff --git a/vendor/github.com/nats-io/jwt/validation.go b/vendor/github.com/nats-io/jwt/validation.go index 9ea774187a..c725218c46 100644 --- a/vendor/github.com/nats-io/jwt/validation.go +++ b/vendor/github.com/nats-io/jwt/validation.go @@ -1,6 +1,9 @@ package jwt -import "fmt" +import ( + "errors" + "fmt" +) // ValidationIssue represents an issue during JWT validation, it may or may not be a blocking error type ValidationIssue struct { @@ -76,3 +79,14 @@ func (v *ValidationResults) IsBlocking(includeTimeChecks bool) bool { func (v *ValidationResults) IsEmpty() bool { return len(v.Issues) == 0 } + +// Errors returns only blocking issues as errors +func (v *ValidationResults) Errors() []error { + var errs []error + for _, v := range v.Issues { + if v.Blocking { + errs = append(errs, errors.New(v.Description)) + } + } + return errs +} diff --git a/vendor/manifest b/vendor/manifest index b6883f130c..d0780894c4 100644 --- a/vendor/manifest +++ b/vendor/manifest @@ -5,7 +5,7 @@ "importpath": "github.com/nats-io/jwt", "repository": "https://github.com/nats-io/jwt", "vcs": "git", - "revision": "f26fb76c5f45b9fe3e657a1135d795079cecffac", + "revision": "cad7522beb57f4823c682c3b63d53bcb3bf1cf3d", "branch": "master", "notests": true },