Class: Signature5Verifier

Inherits:
Object
  • Object
show all
Defined in:
lib/ruby-common/Signature5Verifier.rb

Overview

Entry point of AdScore signature v5 verification library. It expose verify method allowing to verify

AdScore signature against given set of ipAddress(es) for given zone.

V5 is in fact an encrypted payload containing various metadata about the traffic.
Its decryption does not rely on IP address nor User Agent string,
so it is immune for environment changes usually preventing V4 to be even decoded.
result is also included in the payload, but client doing the integration can make its own decision basing on the metadata accompanying.

Class Method Summary collapse

Class Method Details

.verify(signature, user_agent, key, ip_addresses) ⇒ Object

Verifies the signature against the provided user agent, key, and IP addresses.

Parameters:

  • signature

    The string which we want to verify.

  • user_agent

    String with full description of user agent like ‘Mozilla/5.0 (Linux; Android 9; SM-J530F)…’.

  • keywhichyoumightfindinpage. ("Zone Response Key""Zone Encryption")

    ey “Zone Response Key” which you might find in “Zone Encryption” page.

  • ip_addresses

    List of strings containing IPv4 or IPv6 addresses against which we check signature. Usually fulfilled from httpXForwardForIpAddresses or/and remoteIpAddresses header. All possible IP addresses may be provided at once; the verifier returns a list of chosen IP addresses that matched with the signature.

Returns:

  • Signature5VerificationResult object representing the result of the signature verification.

  • Signature5VerificationResult

Raises:

  • VersionError If there is an error related to version parsing or compatibility.

  • ParseError If there is an error parsing the signature or during decryption process

  • VerifyError If there is an error during verify decrypted Signature



28
29
30
# File 'lib/ruby-common/Signature5Verifier.rb', line 28

def self.verify(signature, user_agent, key, ip_addresses)
  Signature5VerifierService.verifySignature(signature, user_agent, key, ip_addresses)
end