File tree Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Expand file tree Collapse file tree 1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -4,14 +4,15 @@ import (
4
4
"encoding/json"
5
5
"errors"
6
6
"fmt"
7
- "github.com/datreeio/admission-webhook-datree/pkg/openshiftService"
8
7
"net/http"
9
8
"os"
10
9
"regexp"
11
10
"strings"
12
11
"sync"
13
12
"time"
14
13
14
+ "github.com/datreeio/admission-webhook-datree/pkg/openshiftService"
15
+
15
16
authenticationv1 "k8s.io/api/authentication/v1"
16
17
17
18
"github.com/datreeio/admission-webhook-datree/pkg/errorReporter"
@@ -412,9 +413,6 @@ func (vs *ValidationService) shouldBypassByPermissions(userInfo authenticationv1
412
413
userName := userInfo .Username
413
414
groups := userInfo .Groups
414
415
if openShiftRequester != "" {
415
- // override username
416
- userName = openShiftRequester
417
-
418
416
// override groups
419
417
groupsFromOpenshiftService , err := vs .OpenshiftService .GetGroupsUserBelongsTo (openShiftRequester )
420
418
if err != nil {
@@ -425,8 +423,16 @@ func (vs *ValidationService) shouldBypassByPermissions(userInfo authenticationv1
425
423
}
426
424
427
425
for _ , userAccount := range bypassPermissions .UserAccounts {
428
- if match , _ := regexp .MatchString (userAccount , userName ); match {
429
- return true
426
+ if openShiftRequester != "" {
427
+ matchOpenshiftRequester , _ := regexp .MatchString (userAccount , openShiftRequester )
428
+ if matchOpenshiftRequester {
429
+ return true
430
+ }
431
+ } else {
432
+ matchUsername , _ := regexp .MatchString (userAccount , userName )
433
+ if matchUsername {
434
+ return true
435
+ }
430
436
}
431
437
}
432
438
You can’t perform that action at this time.
0 commit comments