Skip to content

Commit

Permalink
Merge pull request cloudflare#786 from jgpaiva/jpaiva/GATE-2386-add-t…
Browse files Browse the repository at this point in the history
…errafor-for-warp-session

GATE-2386: Adds support for missing team rules settings
  • Loading branch information
jacobbednarz authored Jan 24, 2022
2 parents ffdd105 + 5706517 commit 2bd8514
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 6 deletions.
14 changes: 14 additions & 0 deletions teams_rules.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,14 @@ type TeamsRuleSettings struct {
// settings for l4(network) level overrides
L4Override *TeamsL4OverrideSettings `json:"l4override"`

// settings for adding headers to http requests
AddHeaders http.Header `json:"add_headers"`

// settings for browser isolation actions
BISOAdminControls *TeamsBISOAdminControlSettings `json:"biso_admin_controls"`

// settings for session check in allow action
CheckSession *TeamsCheckSessionSettings `json:"check_session"`
}

// TeamsL4OverrideSettings used in l4 filter type rule with action set to override.
Expand All @@ -39,6 +45,14 @@ type TeamsL4OverrideSettings struct {
type TeamsBISOAdminControlSettings struct {
DisablePrinting bool `json:"dp"`
DisableCopyPaste bool `json:"dcp"`
DisableDownload bool `json:"dd"`
DisableUpload bool `json:"du"`
DisableKeyboard bool `json:"dk"`
}

type TeamsCheckSessionSettings struct {
Enforce bool `json:"enforce"`
Duration Duration `json:"duration"`
}

type TeamsFilterType string
Expand Down
50 changes: 44 additions & 6 deletions teams_rules_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,11 @@ func TestTeamsRules(t *testing.T) {
"override_host": "",
"l4override": null,
"biso_admin_controls": null,
"add_headers": null
"add_headers": null,
"check_session": {
"enforce": true,
"duration": "15m0s"
}
}
},
{
Expand All @@ -71,7 +75,8 @@ func TestTeamsRules(t *testing.T) {
"override_host": "",
"l4override": null,
"biso_admin_controls": null,
"add_headers": null
"add_headers": null,
"check_session": null
}
}
]
Expand Down Expand Up @@ -100,7 +105,12 @@ func TestTeamsRules(t *testing.T) {
OverrideIPs: nil,
OverrideHost: "",
L4Override: nil,
AddHeaders: nil,
BISOAdminControls: nil,
CheckSession: &TeamsCheckSessionSettings{
Enforce: true,
Duration: Duration{900 * time.Second},
},
},
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
Expand All @@ -124,7 +134,9 @@ func TestTeamsRules(t *testing.T) {
OverrideIPs: nil,
OverrideHost: "",
L4Override: nil,
AddHeaders: nil,
BISOAdminControls: nil,
CheckSession: nil,
},
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
Expand Down Expand Up @@ -174,7 +186,11 @@ func TestTeamsRule(t *testing.T) {
"override_host": "",
"l4override": null,
"biso_admin_controls": null,
"add_headers": null
"add_headers": null,
"check_session": {
"enforce": true,
"duration": "15m0s"
}
}
}
}
Expand Down Expand Up @@ -202,7 +218,12 @@ func TestTeamsRule(t *testing.T) {
OverrideIPs: nil,
OverrideHost: "",
L4Override: nil,
AddHeaders: nil,
BISOAdminControls: nil,
CheckSession: &TeamsCheckSessionSettings{
Enforce: true,
Duration: Duration{900 * time.Second},
},
},
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
Expand Down Expand Up @@ -247,7 +268,13 @@ func TestTeamsCreateRule(t *testing.T) {
"override_host": "",
"l4override": null,
"biso_admin_controls": null,
"add_headers": null
"add_headers": {
"X-Test": ["abcd"]
},
"check_session": {
"enforce": true,
"duration": "5m0s"
}
}
}
}
Expand All @@ -270,7 +297,12 @@ func TestTeamsCreateRule(t *testing.T) {
OverrideIPs: nil,
OverrideHost: "",
L4Override: nil,
AddHeaders: http.Header{"X-Test": []string{"abcd"}},
BISOAdminControls: nil,
CheckSession: &TeamsCheckSessionSettings{
Enforce: true,
Duration: Duration{300 * time.Second},
},
},
DeletedAt: nil,
}
Expand Down Expand Up @@ -316,7 +348,8 @@ func TestTeamsUpdateRule(t *testing.T) {
"override_host": "",
"l4override": null,
"biso_admin_controls": null,
"add_headers": null
"add_headers": null,
"check_session": null
}
}
}
Expand All @@ -343,7 +376,9 @@ func TestTeamsUpdateRule(t *testing.T) {
OverrideIPs: nil,
OverrideHost: "",
L4Override: nil,
AddHeaders: nil,
BISOAdminControls: nil,
CheckSession: nil,
},
CreatedAt: &createdAt,
UpdatedAt: &updatedAt,
Expand Down Expand Up @@ -383,7 +418,8 @@ func TestTeamsPatchRule(t *testing.T) {
"override_host": "",
"l4override": null,
"biso_admin_controls": null,
"add_headers": null
"add_headers": null,
"check_session": null
}
}
}
Expand All @@ -402,7 +438,9 @@ func TestTeamsPatchRule(t *testing.T) {
OverrideIPs: nil,
OverrideHost: "",
L4Override: nil,
AddHeaders: nil,
BISOAdminControls: nil,
CheckSession: nil,
},
}

Expand Down

0 comments on commit 2bd8514

Please sign in to comment.