Skip to content

Add DataDome bot protection integration#231

Open
ChristianPavilonis wants to merge 2 commits intomainfrom
feature/datadome-integration-christian
Open

Add DataDome bot protection integration#231
ChristianPavilonis wants to merge 2 commits intomainfrom
feature/datadome-integration-christian

Conversation

@ChristianPavilonis
Copy link
Collaborator

@ChristianPavilonis ChristianPavilonis commented Feb 3, 2026

Closes #61

@ChristianPavilonis ChristianPavilonis force-pushed the feature/datadome-integration-christian branch from 26a3699 to d5f40db Compare February 3, 2026 23:20
@ChristianPavilonis ChristianPavilonis marked this pull request as ready for review February 3, 2026 23:31
@ChristianPavilonis ChristianPavilonis force-pushed the feature/datadome-integration-christian branch from a9f1552 to c6f1536 Compare February 4, 2026 21:28
@ChristianPavilonis ChristianPavilonis force-pushed the feature/datadome-integration-christian branch from c6f1536 to 2143b2b Compare February 4, 2026 21:55
# ANY /integrations/datadome/js/* - Signal collection API
[integrations.datadome]
enabled = false
# js_key = "YOUR_DATADOME_JS_KEY" # Optional: for auto-injecting DataDome config
Copy link
Collaborator

@aram356 aram356 Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 js_key not used in the implementation. Is that a mistake?


/// Configuration for `DataDome` integration.
#[derive(Debug, Clone, Deserialize, Validate)]
pub struct DataDomeConfig {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Where is config for js_key?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was dead code.

I'm assuming you mean the datadome public key?
if you see the request to /integrations/datadome/js/ on the test site it has a field for ddk in the body which is the public key.

// - '//js.datadome.co/js/check'
// - "api-js.datadome.co/js/check"
// - "js.datadome.co"
let pattern = Regex::new(r#"(['"])(https?:)?(//)?(api-)?js\.datadome\.co(/[^'"]*)?(['"])"#)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Should be a const with

use once_cell::sync::Lazy;

static DATADOME_URL_PATTERN: Lazy<Regex> = Lazy::new(|| {
    Regex::new(r#"(['"])(https?:)?(//)?(api-)?js\.datadome\.co(/[^'"]*)?(['"])"#)
        .expect("DataDome URL rewrite regex should compile")
});

@@ -0,0 +1,185 @@
import { log } from '../../core/log';
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

❓ Should we have a common JS implementation for this? We have Permutive and Lockr and should have common reusable implementation.

// Invalid:
// - https://cdn.example.com/js.datadome.co.js (domain is not js.datadome.co)
return (
lower.includes('://js.datadome.co/') ||
Copy link
Collaborator

@aram356 aram356 Feb 5, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Seems we can make a little cleaner.

❓ What about api-js.datadome.co urls?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

api-js.datadome.co doesn't load scripts. Those are the api endpoints, so would be unnecessary.

/// Handle the /tags.js endpoint - fetch and rewrite the `DataDome` SDK.
async fn handle_tags_js(
&self,
_settings: &Settings,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Let's not pass parameters we don't need


/// Handle the /js/* signal collection endpoint - proxy pass-through to api-js.datadome.co.
async fn handle_js_api(
&self,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⛏️ Let's not pass parameters we don't need

@@ -0,0 +1,781 @@
//! `DataDome` integration for bot protection and security.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔧 Still need comprehensive summary

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

As publisher I would to use Datadome settings with Trusted Server #15

3 participants