Skip to content

Commit

Permalink
Merge pull request #133 from Edgio/SECC-4962
Browse files Browse the repository at this point in the history
SECC-4962: adding recaptcha and bot manager to scopes
  • Loading branch information
ThrashCollector committed Apr 27, 2023
2 parents 0a4d8fc + f61ba80 commit a15ad3d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 25 deletions.
30 changes: 22 additions & 8 deletions edgecast/waf/scopes/scopes_models.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,26 @@ type Scope struct {
*/
Path MatchCondition `json:"path"`

/*
Indicates the name assigned to the action that will take place when the bot manager with recaptcha type
defined within the BotManagerConfigId property is violated.
*/
ReCaptchaActionName *string `json:"recaptcha_action_name"`

/*
Indicates the secret key assigned to the bot manager with recaptcha type
defined within the BotManagerConfigId property.
*/
ReCaptchaSecretKey *string `json:"recaptcha_secret_key"`

/*
Indicates the reCaptcha site key assigned to the bot manager with recaptcha type
defined within the BotManagerConfigId property.
*/
ReCaptchaSiteKey *string `json:"recaptcha_site_key"`

/*
Describe the type of action that will take place when the access rule
defined within the ACLAuditID property is violated.
Expand Down Expand Up @@ -138,17 +158,11 @@ type Scope struct {
ACLProdID *string `json:"acl_prod_id,omitempty"`

/*
Indicates the system-defined ID for the bots rule that will be applied
Indicates the system-defined ID for the bot manager that will be applied
to production traffic for this Security Application Manager
configuration.
*/
BotsProdID *string `json:"bots_prod_id,omitempty"`

/*
Describes the type of action that will take place when the bots rule
defined within the BotsProdID property is violated.
*/
BotsProdAction *ProdAction `json:"bots_prod_action,omitempty"`
BotManagerConfigId *string `json:"bot_manager_config_id,omitempty"`

/*
Describes the type of action that will take place when the managed rule
Expand Down
39 changes: 22 additions & 17 deletions example/waf/security_application_manager/scopes.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ func main() {
accessRuleID := "ACCESS_RULE_ID"
managedRuleID := "MANAGED_RULE_ID"
customRuleID := "CUSTOM_RULE_ID"
botRuleID := "BOT_RULE_ID"
botManagerConfigId := "BOT_MANAGER_ID"
reCaptchaActionName := "edgio_bot"
reCaptchaSecretKey := "2Phg5FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF1vkF"
reCaptchaSiteKey := "6Lcm3XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX5mfX"

sdkConfig := edgecast.NewSDKConfig()
sdkConfig.APIToken = apiToken
Expand All @@ -50,8 +53,6 @@ func main() {
trueVar := true
encodedMessage := base64.StdEncoding.EncodeToString([]byte("hello!"))
status404 := 404
status200 := 200 // used by bot rule
validForSec := 300 // used by bot rule
redirectURL := "https://www.mysite.com/redirected"

scope := scopes.Scope{
Expand All @@ -61,6 +62,9 @@ func main() {
IsCaseInsensitive: &trueVar,
Values: &[]string{"mysite.com", "mysite2.com"},
},
ReCaptchaActionName: &reCaptchaActionName,
ReCaptchaSecretKey: &reCaptchaSecretKey,
ReCaptchaSiteKey: &reCaptchaSiteKey,
Path: scopes.MatchCondition{
Type: "EM",
Values: &[]string{"/account", "/admin"},
Expand Down Expand Up @@ -98,13 +102,7 @@ func main() {
ENFType: "ALERT",
},

BotsProdID: &botRuleID,
BotsProdAction: &scopes.ProdAction{
Name: "Bot Rule Action",
ENFType: "BROWSER_CHALLENGE",
Status: &status200,
ValidForSec: &validForSec,
},
BotManagerConfigId: &botManagerConfigId,
}

modifyResp, err := wafService.Scopes.ModifyAllScopes(
Expand Down Expand Up @@ -216,6 +214,18 @@ func PrintScope(scope scopes.Scope) {
fmt.Println("\tPath:")
PrintMatchCondition(scope.Path)

if scope.ReCaptchaActionName != nil {
fmt.Printf("\tReCaptchaActionName:%s\n", *scope.ReCaptchaActionName)
}

if scope.ReCaptchaSecretKey != nil {
fmt.Printf("\tReCaptchaSecretKey:%s\n", *scope.ReCaptchaSecretKey)
}

if scope.ReCaptchaSiteKey != nil {
fmt.Printf("\tReCaptchaSitetKey:%s\n", *scope.ReCaptchaSiteKey)
}

if scope.Limits != nil {
fmt.Println("\tLimits:")
PrintLimits(*scope.Limits)
Expand All @@ -239,13 +249,8 @@ func PrintScope(scope scopes.Scope) {
PrintProdAction(*scope.ACLProdAction)
}

if scope.BotsProdID != nil {
fmt.Printf("\tBotsProdID:%s\n", *scope.BotsProdID)
}

if scope.BotsProdAction != nil {
fmt.Println("\tBotsProdAction:")
PrintProdAction(*scope.BotsProdAction)
if scope.BotManagerConfigId != nil {
fmt.Printf("\tBotManagerConfigId:%s\n", *scope.BotManagerConfigId)
}

if scope.ProfileAuditID != nil {
Expand Down

0 comments on commit a15ad3d

Please sign in to comment.