Skip to content

Commit

Permalink
[ADS-276] Add info, that ipAddresses may contain multiple addresses
Browse files Browse the repository at this point in the history
SignatureVerifier may take multiple ipAddresses as parameter,
from multiple sources (e.g httpXForwardForIpAddresses
 and remoteIpAddresses headers), internally check
 all against signature and in case of the correct result
 returns IPs that matched with the signature.
  • Loading branch information
iterativepianist committed Mar 1, 2021
1 parent ba88969 commit 953b9f7
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 5 deletions.
6 changes: 5 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,9 @@ The definition of verify function looks as follows:
* customers this should be always set to 'customer'
* @param key string containing related zone key
* @param ipAddresses array of strings containing ip4 or ip6 addresses against which we check
* signature
* signature. Usually, is fulfilled from httpXForwardForIpAddresses or/and remoteIpAddresses
* header. All possible ip addresses may be provided at once, in case of correct result,
* verifier returns list of chosen ip addresses that matched with the signature.
* @param expiry number which is time in seconds. IF signatureTime + expiry > CurrentDateInSeconds
* THEN result is expired. If null than expiry is not checked.
* @param isKeyBase64Encoded boolean defining if passed key is base64 encoded or not
Expand Down Expand Up @@ -175,6 +177,8 @@ than you have at least few options of how to verify signatures:
"customer",
"key_non_base64_encoded",
false, // notify that we use non encoded key

//Multiple ip addresses either from httpXForwardForIpAddresses and remoteIpAddresses header
"73.109.57.137", "73.109.57.138", "73.109.57.139", "73.109.57.140", "0:0:0:0:0:ffff:4d73:55d3", "0:0:0:0:0:fffff:4d73:55d4", "0:0:0:0:0:fffff:4d73:55d5", "0:0:0:0:0:fffff:4d73:55d6");
[..]

Expand Down
16 changes: 12 additions & 4 deletions src/main/java/com/adscore/signature/SignatureVerifier.java
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ public class SignatureVerifier {
* customers this should be always set to 'customer'
* @param key string containing related zone key
* @param ipAddresses array of strings containing ip4 or ip6 addresses against which we check
* signature
* signature. Usually, is fulfilled from httpXForwardForIpAddresses or/and remoteIpAddresses
* header. All possible ip addresses may be provided at once, in case of correct result,
* verifier returns list of chosen ip addresses that matched with the signature.
* @return VerificationResult
*/
public static SignatureVerificationResult verify(
Expand All @@ -61,7 +63,9 @@ public static SignatureVerificationResult verify(
* customers this should be always set to 'customer'
* @param key string containing related zone key
* @param ipAddresses array of strings containing ip4 or ip6 addresses against which we check
* signature
* signature. Usually, is fulfilled from httpXForwardForIpAddresses or/and remoteIpAddresses
* header. All possible ip addresses may be provided at once, in case of correct result,
* verifier returns list of chosen ip addresses that matched with the signature.
* @param expiry number which is time in seconds. IF signatureTime + expiry > CurrentDateInSeconds
* THEN result is expired
* @return VerificationResult
Expand All @@ -87,7 +91,9 @@ public static SignatureVerificationResult verify(
* customers this should be always set to 'customer'
* @param key string containing related zone key
* @param ipAddresses array of strings containing ip4 or ip6 addresses against which we check
* signature
* signature. Usually, is fulfilled from httpXForwardForIpAddresses or/and remoteIpAddresses
* header. All possible ip addresses may be provided at once, in case of correct result,
* verifier returns list of chosen ip addresses that matched with the signature.
* @param isKeyBase64Encoded boolean defining if passed key is base64 encoded or not
* @return VerificationResult
*/
Expand Down Expand Up @@ -117,7 +123,9 @@ public static SignatureVerificationResult verify(
* customers this should be always set to 'customer'
* @param key string containing related zone key
* @param ipAddresses array of strings containing ip4 or ip6 addresses against which we check
* signature
* signature. Usually, is fulfilled from httpXForwardForIpAddresses or/and remoteIpAddresses
* header. All possible ip addresses may be provided at once, in case of correct result,
* verifier returns list of chosen ip addresses that matched with the signature.
* @param expiry number which is time in seconds. IF signatureTime + expiry > CurrentDateInSeconds
* THEN result is expired
* @param isKeyBase64Encoded boolean defining if passed key is base64 encoded or not
Expand Down

0 comments on commit 953b9f7

Please sign in to comment.