-
Notifications
You must be signed in to change notification settings - Fork 14
Added CTS and user identifiers features [ENT-22836] #219
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
7673942
Merge pull request #217 from HumanSecurity/release/v4.0.1
DorAshkenaziHuman 287b0e6
Implement user identifiers and CTS features, in addition to sensitive…
DorAshkenaziHuman 167fb01
Added changelog, readme and test adapter
DorAshkenaziHuman fa0d3fc
PR Changes
DorAshkenaziHuman f013816
Added px_cookie to block activities
DorAshkenaziHuman File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,115 @@ | ||
| <?php | ||
| /** | ||
| * Test Adapter for PerimeterX Enforcer Spec Tests | ||
| * | ||
| * Loads configuration from enforcer_config.json and runs pxVerify. | ||
| * Translates spec test config names (px_*) to PHP SDK config names. | ||
| * | ||
| * Usage: php -S localhost:3000 test-adapter.php | ||
| */ | ||
|
|
||
| require __DIR__ . "/../vendor/autoload.php"; | ||
|
|
||
| use Perimeterx\Perimeterx; | ||
|
|
||
| // Config key translation: spec test names (px_*) => PHP SDK names | ||
| // null = keep the key as-is (SDK expects it with px_ prefix) | ||
| $CONFIG_MAP = [ | ||
| // Keys that need translation (spec tests use different names than SDK) | ||
| 'px_app_id' => 'app_id', | ||
| 'px_auth_token' => 'auth_token', | ||
| 'px_cookie_secret' => 'cookie_key', | ||
| 'px_module_enabled' => 'module_enabled', | ||
| 'px_blocking_score' => 'blocking_score', | ||
| 'px_module_mode' => 'module_mode', | ||
| 'px_backend_url' => 'perimeterx_server_host', | ||
| 'px_s2s_timeout' => 'api_timeout', | ||
| 'px_api_timeout' => 'api_timeout', | ||
| 'px_sensitive_routes' => 'sensitive_routes', | ||
| 'px_sensitive_headers' => 'sensitive_headers', | ||
| 'px_ip_headers' => 'ip_headers', | ||
| // Keys that keep px_ prefix (SDK expects it as-is) | ||
| 'px_first_party_enabled' => null, | ||
| 'px_cd_first_party_enabled' => null, | ||
| 'px_jwt_cookie_name' => null, | ||
| 'px_jwt_cookie_user_id_field_name' => null, | ||
| 'px_jwt_cookie_additional_field_names' => null, | ||
| 'px_jwt_header_name' => null, | ||
| 'px_jwt_header_user_id_field_name' => null, | ||
| 'px_jwt_header_additional_field_names' => null, | ||
| 'px_login_credentials_extraction_enabled' => null, | ||
| 'px_login_credentials_extraction' => null, | ||
| 'px_compromised_credentials_header' => null, | ||
| 'px_credentials_intelligence_version' => null, | ||
| 'px_additional_s2s_activity_header_enabled' => null, | ||
| 'px_automatic_additional_s2s_activity_enabled' => null, | ||
| 'px_send_raw_username_on_additional_s2s_activity' => null, | ||
| 'px_login_successful_reporting_method' => null, | ||
| 'px_login_successful_status' => null, | ||
| 'px_login_successful_header_name' => null, | ||
| 'px_login_successful_header_value' => null, | ||
| ]; | ||
|
|
||
| /** | ||
| * Translate spec test config (px_* names) to PHP SDK config names | ||
| */ | ||
| function translateConfig(array $config, array $configMap): array { | ||
| $translated = []; | ||
|
|
||
| foreach ($config as $key => $value) { | ||
| if (array_key_exists($key, $configMap)) { | ||
| $mappedKey = $configMap[$key]; | ||
| $translated[$mappedKey ?? $key] = $value; | ||
| } elseif (strpos($key, 'px_') === 0) { | ||
| // Unmapped px_* keys: strip prefix | ||
| $translated[substr($key, 3)] = $value; | ||
| } else { | ||
| $translated[$key] = $value; | ||
| } | ||
| } | ||
|
|
||
| // Translate module_mode string to SDK constant | ||
| if (isset($translated['module_mode']) && is_string($translated['module_mode'])) { | ||
| $mode = strtolower($translated['module_mode']); | ||
| if ($mode === 'monitor' || $mode === 'monitoring') { | ||
| $translated['module_mode'] = Perimeterx::$MONITOR_MODE; | ||
| } elseif ($mode === 'active_blocking' || $mode === 'blocking' || $mode === 'active') { | ||
| $translated['module_mode'] = Perimeterx::$ACTIVE_MODE; | ||
| } | ||
| } | ||
|
|
||
| return $translated; | ||
| } | ||
|
|
||
| // Load config from JSON file | ||
| $configFile = __DIR__ . '/enforcer_config.json'; | ||
| if (!file_exists($configFile)) { | ||
| http_response_code(200); | ||
| echo 'OK'; | ||
| exit; | ||
| } | ||
|
|
||
| $fileConfig = json_decode(file_get_contents($configFile), true); | ||
| if ($fileConfig === null) { | ||
| http_response_code(200); | ||
| echo 'OK'; | ||
| exit; | ||
| } | ||
|
|
||
| $config = translateConfig($fileConfig, $CONFIG_MAP); | ||
|
|
||
| // Validate required config | ||
| if (empty($config['app_id']) || empty($config['cookie_key']) || empty($config['auth_token'])) { | ||
| http_response_code(200); | ||
| echo 'OK'; | ||
| exit; | ||
| } | ||
|
|
||
| // Run the enforcer | ||
| try { | ||
| $px = Perimeterx::Instance($config); | ||
| $px->pxVerify(); | ||
| } catch (Exception $e) { | ||
| http_response_code(200); | ||
| echo 'OK'; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,6 +26,7 @@ | |
| "risk_api", | ||
| "sensitive_headers", | ||
| "sensitive_routes", | ||
| "vid_extraction" | ||
| "vid_extraction", | ||
| "user_identifiers" | ||
| ] | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.