Skip to content
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

Add IPGEO to DFP rules endpoint #58

Merged
merged 2 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/workflows/rust.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@1.73
- uses: dtolnay/rust-toolchain@1.80
with:
components: rustfmt

Expand All @@ -24,7 +24,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@1.73
- uses: dtolnay/rust-toolchain@1.80
with:
components: clippy

Expand All @@ -41,7 +41,7 @@ jobs:
steps:
- uses: actions/checkout@v4

- uses: dtolnay/rust-toolchain@1.73
- uses: dtolnay/rust-toolchain@1.80

- uses: Swatinem/rust-cache@v2

Expand Down
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "stytch"
version = "7.6.0"
version = "7.7.0"
edition = "2021"
license = "MIT"
description = "Stytch Rust client"
Expand Down
28 changes: 28 additions & 0 deletions src/consumer/fraud.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,13 @@
pub struct Verdict {
/// action: The suggested action based on the fingerprint review. The available actions are:
/// * `ALLOW` - This is a known valid device grouping or device profile that is part of the default ALLOW
/// listed set of known devices by Stytch. This grouping is made up of verified device profiles that match

Check warning on line 89 in src/consumer/fraud.rs

View workflow job for this annotation

GitHub Actions / clippy

doc list item missing indentation

warning: doc list item missing indentation --> src/consumer/fraud.rs:89:9 | 89 | /// listed set of known devices by Stytch. This grouping is made up of verified device profiles that match | ^ | = help: if this is supposed to be its own paragraph, add a blank line = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation help: indent this line | 89 | /// listed set of known devices by Stytch. This grouping is made up of verified device profiles that match | ++++
/// the characteristics of known/authentic traffic origins

Check warning on line 90 in src/consumer/fraud.rs

View workflow job for this annotation

GitHub Actions / clippy

doc list item missing indentation

warning: doc list item missing indentation --> src/consumer/fraud.rs:90:9 | 90 | /// the characteristics of known/authentic traffic origins | ^ | = help: if this is supposed to be its own paragraph, add a blank line = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation help: indent this line | 90 | /// the characteristics of known/authentic traffic origins | ++++
/// * `BLOCK` - This is a known bad or malicious device profile that is undesirable and should be blocked
/// from completing the privileged action in question

Check warning on line 92 in src/consumer/fraud.rs

View workflow job for this annotation

GitHub Actions / clippy

doc list item missing indentation

warning: doc list item missing indentation --> src/consumer/fraud.rs:92:9 | 92 | /// from completing the privileged action in question | ^ | = help: if this is supposed to be its own paragraph, add a blank line = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation help: indent this line | 92 | /// from completing the privileged action in question | ++++
/// * `CHALLENGE` - This is an unknown or potentially malicious device that should be put through
/// increased friction such as 2FA or other forms of extended user verification before allowing the

Check warning on line 94 in src/consumer/fraud.rs

View workflow job for this annotation

GitHub Actions / clippy

doc list item missing indentation

warning: doc list item missing indentation --> src/consumer/fraud.rs:94:9 | 94 | /// increased friction such as 2FA or other forms of extended user verification before allowing the | ^ | = help: if this is supposed to be its own paragraph, add a blank line = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation help: indent this line | 94 | /// increased friction such as 2FA or other forms of extended user verification before allowing the | ++++
/// privileged action to proceed

Check warning on line 95 in src/consumer/fraud.rs

View workflow job for this annotation

GitHub Actions / clippy

doc list item missing indentation

warning: doc list item missing indentation --> src/consumer/fraud.rs:95:9 | 95 | /// privileged action to proceed | ^ | = help: if this is supposed to be its own paragraph, add a blank line = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#doc_lazy_continuation help: indent this line | 95 | /// privileged action to proceed | ++++
///
pub action: VerdictAction,
/// reasons: A set of contextual clues to inform why a `CHALLENGE` or `BLOCK` action was suggested. For a
Expand All @@ -103,6 +103,12 @@
/// is_authentic_device: The assessment of whether this is an authentic device. It will be false if hardware
/// or browser deception is detected.
pub is_authentic_device: bool,
/// rule_match_type: The type of rule match that was applied (e.g. `VISITOR_ID`), if any. This field will
/// only be present if there is a `RULE_MATCH` reason in the list of verdict reasons.
pub rule_match_type: std::option::Option<RuleType>,
/// rule_match_identifier: The rule that was applied (e.g. a specific visitor ID value), if any. This field
/// will only be present if there is a `RULE_MATCH` reason in the list of verdict reasons.
pub rule_match_identifier: std::option::Option<String>,
}

#[derive(Serialize, Deserialize, Debug, Clone, Default)]
Expand All @@ -118,6 +124,28 @@
NONE,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum RuleType {
#[serde(rename = "VISITOR_ID")]
#[default]
VISITORID,
#[serde(rename = "BROWSER_ID")]
BROWSERID,
#[serde(rename = "VISITOR_FINGERPRINT")]
VISITORFINGERPRINT,
#[serde(rename = "BROWSER_FINGERPRINT")]
BROWSERFINGERPRINT,
#[serde(rename = "HARDWARE_FINGERPRINT")]
HARDWAREFINGERPRINT,
#[serde(rename = "NETWORK_FINGERPRINT")]
NETWORKFINGERPRINT,
#[serde(rename = "CIDR_BLOCK")]
CIDRBLOCK,
#[serde(rename = "ASN")]
ASN,
#[serde(rename = "COUNTRY_CODE")]
COUNTRYCODE,
}
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub enum VerdictAction {
#[serde(rename = "ALLOW")]
#[default]
Expand Down
58 changes: 38 additions & 20 deletions src/consumer/fraud_rules.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,33 +10,45 @@ use serde::{Deserialize, Serialize};
/// SetRequest: Request type for `Rules.set`.
#[derive(Serialize, Deserialize, Debug, Clone, Default)]
pub struct SetRequest {
/// action: The action that should be returned by a fingerprint lookup for that fingerprint or ID with a
/// `RULE_MATCH` reason. The following values are valid: `ALLOW`, `BLOCK`, `CHALLENGE`, or `NONE`. If a
/// `NONE` action is specified, it will clear the stored rule.
/// action: The action that should be returned by a fingerprint lookup for that identifier with a
/// `RULE_MATCH` reason. The following values are valid: `ALLOW`, `BLOCK`, `CHALLENGE`, or `NONE`. For
/// country codes, `ALLOW` actions are not allowed. If a `NONE` action is specified, it will clear the
/// stored rule.
pub action: RuleAction,
/// visitor_id: The visitor ID we want to set a rule for. Only one fingerprint or ID can be specified in the
/// visitor_id: The visitor ID we want to set a rule for. Only one identifier can be specified in the
/// request.
pub visitor_id: std::option::Option<String>,
/// browser_id: The browser ID we want to set a rule for. Only one fingerprint or ID can be specified in the
/// browser_id: The browser ID we want to set a rule for. Only one identifier can be specified in the
/// request.
pub browser_id: std::option::Option<String>,
/// visitor_fingerprint: The visitor fingerprint we want to set a rule for. Only one fingerprint or ID can
/// be specified in the request.
/// visitor_fingerprint: The visitor fingerprint we want to set a rule for. Only one identifier can be
/// specified in the request.
pub visitor_fingerprint: std::option::Option<String>,
/// browser_fingerprint: The browser fingerprint we want to set a rule for. Only one fingerprint or ID can
/// be specified in the request.
/// browser_fingerprint: The browser fingerprint we want to set a rule for. Only one identifier can be
/// specified in the request.
pub browser_fingerprint: std::option::Option<String>,
/// hardware_fingerprint: The hardware fingerprint we want to set a rule for. Only one fingerprint or ID can
/// be specified in the request.
/// hardware_fingerprint: The hardware fingerprint we want to set a rule for. Only one identifier can be
/// specified in the request.
pub hardware_fingerprint: std::option::Option<String>,
/// network_fingerprint: The network fingerprint we want to set a rule for. Only one fingerprint or ID can
/// be specified in the request.
/// network_fingerprint: The network fingerprint we want to set a rule for. Only one identifier can be
/// specified in the request.
pub network_fingerprint: std::option::Option<String>,
/// expires_in_minutes: The number of minutes until this rule expires. If no `expires_in_minutes` is
/// specified, then the rule is kept permanently.
pub expires_in_minutes: std::option::Option<i32>,
/// description: An optional description for the rule.
pub description: std::option::Option<String>,
/// cidr_block: The CIDR block we want to set a rule for. You may pass either an IP address or a CIDR block.
/// The CIDR block prefix must be between 16 and 32, inclusive. If an end user's IP address is within this
/// CIDR block, this rule will be applied. Only one identifier can be specified in the request.
pub cidr_block: std::option::Option<String>,
/// country_code: The country code we want to set a rule for. The country code must be a valid ISO 3166-1
/// alpha-2 code. You may not set `ALLOW` rules for country codes. Only one identifier can be specified in
/// the request.
pub country_code: std::option::Option<String>,
/// asn: The ASN we want to set a rule for. The ASN must be the string representation of an integer between
/// 0 and 4294967295, inclusive. Only one identifier can be specified in the request.
pub asn: std::option::Option<String>,
}
/// SetResponse: Response type for `Rules.set`.
#[derive(Serialize, Deserialize, Debug, Clone)]
Expand All @@ -52,22 +64,28 @@ pub struct SetResponse {
/// are server errors.
#[serde(with = "http_serde::status_code")]
pub status_code: http::StatusCode,
/// visitor_id: The cookie stored on the user's device that uniquely identifies them.
/// visitor_id: The visitor ID that a rule was set for.
pub visitor_id: std::option::Option<String>,
/// browser_id: Combination of VisitorID and NetworkFingerprint to create a clear identifier of a browser.
/// browser_id: The browser ID that a rule was set for.
pub browser_id: std::option::Option<String>,
/// visitor_fingerprint: Cookie-less way of identifying a unique user.
/// visitor_fingerprint: The visitor fingerprint that a rule was set for.
pub visitor_fingerprint: std::option::Option<String>,
/// browser_fingerprint: Combination of signals to identify a browser and its specific version.
/// browser_fingerprint: The browser fingerprint that a rule was set for.
pub browser_fingerprint: std::option::Option<String>,
/// hardware_fingerprint: Combinations of signals to identify an operating system and architecture.
/// hardware_fingerprint: The hardware fingerprint that a rule was set for.
pub hardware_fingerprint: std::option::Option<String>,
/// network_fingerprint: Combination of signals associated with a specific network commonly known as TLS
/// fingerprinting.
/// network_fingerprint: The network fingerprint that a rule was set for.
pub network_fingerprint: std::option::Option<String>,
/// expires_at: The timestamp when the rule expires. Values conform to the RFC 3339 standard and are
/// expressed in UTC, e.g. `2021-12-29T12:33:09Z`.
pub expires_at: std::option::Option<chrono::DateTime<chrono::Utc>>,
/// cidr_block: The CIDR block that a rule was set for. If an end user's IP address is within this CIDR
/// block, this rule will be applied.
pub cidr_block: std::option::Option<String>,
/// country_code: The country code that a rule was set for.
pub country_code: std::option::Option<String>,
/// asn: The ASN that a rule was set for.
pub asn: std::option::Option<String>,
}

pub struct Rules {
Expand Down
Loading