Skip to content

Commit

Permalink
Fix: Authentication validation for MTLS
Browse files Browse the repository at this point in the history
  • Loading branch information
BLasan committed Jul 11, 2023
1 parent 8bb48b1 commit 86dc66c
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,16 +83,15 @@ func (r *Authentication) validateAuthentication() error {
const mltsMandatory = "mandatory"
mtlsOverride := r.Spec.Override.MutualSSL
mtlsDefault := r.Spec.Default.MutualSSL
fmt.Println("mtlsOverride", mtlsOverride)
if mtlsOverride != "" && mtlsDefault != "" {
if mtlsOverride == "" && mtlsDefault == "" {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("default").Child("mutualSSL"),
r.Spec.Default.MutualSSL, "mutualSSL cannot be empty in both default and override"))
}
if mtlsOverride != "" && (!strings.EqualFold(mtlsDefault, mltsMandatory) || !strings.EqualFold(mtlsDefault, mltsOptional)) {
if mtlsOverride != "" && (!strings.EqualFold(mtlsOverride, mltsMandatory) && !strings.EqualFold(mtlsOverride, mltsOptional)) {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("override").Child("mutualSSL"),
r.Spec.Override.MutualSSL, "invalid value for mutualSSL"))
}
if mtlsDefault != "" && (!strings.EqualFold(mtlsDefault, mltsMandatory) || !strings.EqualFold(mtlsDefault, mltsOptional)) {
if mtlsDefault != "" && (!strings.EqualFold(mtlsDefault, mltsMandatory) && !strings.EqualFold(mtlsDefault, mltsOptional)) {
allErrs = append(allErrs, field.Invalid(field.NewPath("spec").Child("default").Child("mutualSSL"),
r.Spec.Default.MutualSSL, "invalid value for mutualSSL"))
}
Expand Down
4 changes: 2 additions & 2 deletions developer/tryout/samples/sample-auth.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ metadata:
name: sand-http-bin-authentication
spec:
override:
mutualSSL: abc
mutualSSL: optional
type: ext
ext:
disabled: false
Expand All @@ -18,7 +18,7 @@ spec:
- in: Header
name: x-api-key
default:
mutualSSL: optional
mutualSSL: ""
type: ext
ext:
serviceRef:
Expand Down

0 comments on commit 86dc66c

Please sign in to comment.