Skip to content

Commit

Permalink
NSOF-8836 aac_rules: remove suspicious_login field
Browse files Browse the repository at this point in the history
  • Loading branch information
Chen Peled committed May 12, 2024
1 parent adfbed1 commit fe3b122
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 68 deletions.
1 change: 0 additions & 1 deletion docs/data-sources/aac_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,4 +43,3 @@ output "aac_rule" {
- `notification_channels` (List of String) List of notification channel IDs
- `priority` (Number) Determines the order in which the aac rules are being matched. Lower priority indicates that the AAC rule is matched earlier
- `sources` (List of String) Users and groups that the rule is applied to
- `suspicious_login` (String) Determines if the rule applies at suspicious or non-suspicious login. Options: any, suspicious, safe
22 changes: 10 additions & 12 deletions docs/resources/aac_rule.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,17 +14,16 @@ Adaptive access control rule for protecting users connecting to service provider

```terraform
resource "pfptmeta_aac_rule" "aac_rule" {
name = "aac rule name"
description = "aac rule description"
enabled = true
priority = 555
action = "allow"
app_ids = ["app-abcd1234"]
sources = ["usr-abcd1234"]
certificate_id = "crt-abcd1234"
suspicious_login = "safe"
locations = ["US", "IL"]
ip_reputations = ["tor", "vpn"]
name = "aac rule name"
description = "aac rule description"
enabled = true
priority = 555
action = "allow"
app_ids = ["app-abcd1234"]
sources = ["usr-abcd1234"]
certificate_id = "crt-abcd1234"
locations = ["US", "IL"]
ip_reputations = ["tor", "vpn"]
}
```

Expand All @@ -36,7 +35,6 @@ resource "pfptmeta_aac_rule" "aac_rule" {
- `action` (String) The action to enforce when rule is matched to a connection
- `name` (String)
- `priority` (Number) Determines the order in which the aac rules are being matched. Lower priority indicates that the AAC rule is matched earlier
- `suspicious_login` (String) Determines if the rule applies at suspicious or non-suspicious login. Options: any, suspicious, safe

### Optional

Expand Down
21 changes: 10 additions & 11 deletions examples/resources/pfptmeta_aac_rule/resource.tf
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
resource "pfptmeta_aac_rule" "aac_rule" {
name = "aac rule name"
description = "aac rule description"
enabled = true
priority = 555
action = "allow"
app_ids = ["app-abcd1234"]
sources = ["usr-abcd1234"]
certificate_id = "crt-abcd1234"
suspicious_login = "safe"
locations = ["US", "IL"]
ip_reputations = ["tor", "vpn"]
name = "aac rule name"
description = "aac rule description"
enabled = true
priority = 555
action = "allow"
app_ids = ["app-abcd1234"]
sources = ["usr-abcd1234"]
certificate_id = "crt-abcd1234"
locations = ["US", "IL"]
ip_reputations = ["tor", "vpn"]
}
25 changes: 0 additions & 25 deletions internal/client/aac_rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ type AacRule struct {
ApplyAllApps bool `json:"apply_all_apps"`
Sources []string `json:"sources,omitempty"`
ExemptSources []string `json:"exempt_sources,omitempty"`
SuspiciousLogin *bool `json:"suspicious_login"`
FilterExpression *string `json:"filter_expression"`
Networks []string `json:"networks,omitempty"`
Locations *[]string `json:"locations"`
Expand Down Expand Up @@ -75,33 +74,9 @@ func NewAacRule(d *schema.ResourceData) *AacRule {
} else {
res.FilterExpression = nil
}
res.SuspiciousLogin = suspiciousLoginStrToBool(d.Get("suspicious_login").(string))
return res
}

func suspiciousLoginStrToBool(suspiciousLogin string) *bool {
res := new(bool)
switch suspiciousLogin {
case "suspicious":
*res = true
case "safe":
*res = false
default:
return nil
}
return res
}

func ParseAacSuspiciousLoginBoolToStr(aac_rule *AacRule) string {
if aac_rule.SuspiciousLogin == nil {
return "any"
}
if *aac_rule.SuspiciousLogin {
return "suspicious"
}
return "safe"
}

func parseAacRule(resp []byte) (*AacRule, error) {
aac_rule := &AacRule{}
err := json.Unmarshal(resp, aac_rule)
Expand Down
6 changes: 1 addition & 5 deletions internal/provider/aac_rule/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
"net/http"
)

var excludedKeys = []string{"id", "suspicious_login"}
var excludedKeys = []string{"id"}

const (
description = "Adaptive access control rule for protecting users connecting to service provider application " +
Expand All @@ -23,7 +23,6 @@ const (
"apps are specified in app_ids. Note: this attribute overrides app_ids"
sourcesDesc = "Users and groups that the rule is applied to"
exemptSources = "Subgroup of 'sources' to which the AAC rule is not applied"
suspiciousLoginDesc = "Determines if the rule applies at suspicious or non-suspicious login. Options: any, suspicious, safe"
expressionDesc = "Defines filtering expressions to to provide user granularity in AAC rule application"
networksDesc = "List of IP network IDs that the rule is applied to"
locationsDesc = "List of locations that the rule is applied to. Each country is represented by an Alpha-2 code (ISO-3166). Enum: " + common.CountriesDoc
Expand Down Expand Up @@ -51,7 +50,6 @@ func aacRuleRead(ctx context.Context, d *schema.ResourceData, meta interface{})
if err != nil {
return diag.FromErr(err)
}
d.Set("suspicious_login", client.ParseAacSuspiciousLoginBoolToStr(a))
return
}

Expand All @@ -68,7 +66,6 @@ func aacRuleCreate(ctx context.Context, d *schema.ResourceData, meta interface{}
if err != nil {
return diag.FromErr(err)
}
d.Set("suspicious_login", client.ParseAacSuspiciousLoginBoolToStr(a))
return
}

Expand All @@ -85,7 +82,6 @@ func aacRuleUpdate(ctx context.Context, d *schema.ResourceData, meta interface{}
if err != nil {
return diag.FromErr(err)
}
d.Set("suspicious_login", client.ParseAacSuspiciousLoginBoolToStr(a))
return
}

Expand Down
5 changes: 0 additions & 5 deletions internal/provider/aac_rule/data_source.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ func DataSource() *schema.Resource {
Elem: &schema.Schema{Type: schema.TypeString},
Computed: true,
},
"suspicious_login": {
Description: suspiciousLoginDesc,
Type: schema.TypeString,
Computed: true,
},
"filter_expression": {
Description: expressionDesc,
Type: schema.TypeString,
Expand Down
6 changes: 0 additions & 6 deletions internal/provider/aac_rule/resource.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,12 +81,6 @@ func Resource() *schema.Resource {
ValidateDiagFunc: common.ValidateID(false, "usr", "grp"),
},
},
"suspicious_login": {
Description: suspiciousLoginDesc,
Type: schema.TypeString,
Required: true,
ValidateDiagFunc: common.ValidateStringENUM("suspicious", "safe", "any"),
},
"filter_expression": {
Description: expressionDesc,
Type: schema.TypeString,
Expand Down
3 changes: 0 additions & 3 deletions internal/provider/acc_tests/aac_rule_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ resource "pfptmeta_aac_rule" "rule" {
priority = 1
action = "allow"
apply_all_apps = true
suspicious_login = "suspicious"
sources = [data.pfptmeta_user.aac_user_by_email.id]
ip_reputations = ["tor"]
}
Expand All @@ -46,7 +45,6 @@ func TestAccDataSourceAacRule(t *testing.T) {
resource.TestCheckResourceAttr("pfptmeta_aac_rule.rule", "apply_all_apps", "true"),
resource.TestCheckResourceAttr("pfptmeta_aac_rule.rule", "action", "allow"),
resource.TestCheckResourceAttr("pfptmeta_aac_rule.rule", "priority", "1"),
resource.TestCheckResourceAttr("pfptmeta_aac_rule.rule", "suspicious_login", "suspicious"),
resource.TestCheckResourceAttr("pfptmeta_aac_rule.rule", "sources.0", "usr-xN6MCvzmWyvJYdk"),
resource.TestCheckResourceAttr("pfptmeta_aac_rule.rule", "ip_reputations.0", "tor"),
),
Expand All @@ -60,7 +58,6 @@ func TestAccDataSourceAacRule(t *testing.T) {
resource.TestCheckResourceAttr("data.pfptmeta_aac_rule.rule", "apply_all_apps", "true"),
resource.TestCheckResourceAttr("data.pfptmeta_aac_rule.rule", "action", "allow"),
resource.TestCheckResourceAttr("data.pfptmeta_aac_rule.rule", "priority", "1"),
resource.TestCheckResourceAttr("data.pfptmeta_aac_rule.rule", "suspicious_login", "suspicious"),
resource.TestCheckResourceAttr("data.pfptmeta_aac_rule.rule", "sources.0", "usr-xN6MCvzmWyvJYdk"),
resource.TestCheckResourceAttr("data.pfptmeta_aac_rule.rule", "ip_reputations.0", "tor"),
),
Expand Down

0 comments on commit fe3b122

Please sign in to comment.