package main
import (
"context"
"fmt"
"log"
"os"
"github.com/auth0/go-auth0/v2/management"
)
func main() {
client, err := management.New(
context.TODO(),
os.Getenv("AUTH0_DOMAIN"),
management.WithClientCredentials(
os.Getenv("AUTH0_CLIENT_ID"),
os.Getenv("AUTH0_CLIENT_SECRET"),
),
)
if err != nil {
log.Fatalf("Failed to create client: %v", err)
}
// Enable all attack protection features
ctx := context.TODO()
// Enable bot detection
_, err = client.Management.AttackProtection.BotDetection.Update(ctx, &management.UpdateBotDetectionRequestContent{
Enabled: management.Bool(true),
})
if err != nil {
log.Fatalf("Failed to enable bot detection: %v", err)
}
// Enable breached password detection
_, err = client.Management.AttackProtection.BreachedPasswordDetection.Update(ctx, &management.UpdateBreachedPasswordDetectionRequestContent{
Enabled: management.Bool(true),
Method: management.String("standard"),
})
if err != nil {
log.Fatalf("Failed to enable breached password detection: %v", err)
}
// Enable brute force protection
_, err = client.Management.AttackProtection.BruteForceProtection.Update(ctx, &management.UpdateBruteForceProtectionRequestContent{
Enabled: management.Bool(true),
MaxAttempts: management.Int(10),
})
if err != nil {
log.Fatalf("Failed to enable brute force protection: %v", err)
}
fmt.Println("All attack protection features enabled successfully")
}