-
Notifications
You must be signed in to change notification settings - Fork 50
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
Trusted entitlements: Support signing static endpoints #1119
Trusted entitlements: Support signing static endpoints #1119
Conversation
Codecov Report
@@ Coverage Diff @@
## new-trusted-entitlements-signature-format #1119 +/- ##
=============================================================================
+ Coverage 84.91% 85.13% +0.22%
=============================================================================
Files 186 186
Lines 6614 6586 -28
Branches 947 944 -3
=============================================================================
- Hits 5616 5607 -9
+ Misses 622 603 -19
Partials 376 376
|
6575c19
to
d29e3a5
Compare
Backend integration tests are expected to fail until the backend changes have been deployed. I'm also pointing these changes to an integration branch until those changes are deployed. |
false | ||
} | ||
|
||
val needsNonceToPerformSigning: Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is great 👍🏻
@@ -87,14 +96,12 @@ abstract class BaseBackendIntegrationTest { | |||
every { edit() } returns sharedPreferencesEditor | |||
} | |||
eTagManager = ETagManager(sharedPreferences) | |||
signingManager = SigningManager(SignatureVerificationMode.Disabled, appConfig, apiKey()) | |||
signingManager = spyk(SigningManager(signatureVerificationMode, appConfig, apiKey())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here I changed to a spy so we can see and verify the calls more easily, but it's using the actual implementation. Since there is no way to know that the offerings/product-entitlement mapping calls were verified or not, this made easier to make sure we were verifying those endpoints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there is no way to know that the offerings/product-entitlement mapping calls were verified or not
I checked that by using the "fake invalid signature" thing. Did you add a way to do that in Android too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Well, I meant in the "success" case, we should make sure we are verifying the signature. But right now there is no way to detect whether a SUCCESS
or a NOT_REQUESTED
happened. We could maybe if we could verify the logs, but I haven't added that in Android yet. Until then, this makes sure we are at least calling the signingManager.verify
method, so it shouldn't be NOT_REQUESTED
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love it.
@@ -142,6 +143,7 @@ class SigningManager( | |||
) | |||
|
|||
return if (verificationResult) { | |||
verboseLog(NetworkStrings.VERIFICATION_SUCCESS.format(urlPath)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍🏻
@@ -87,14 +96,12 @@ abstract class BaseBackendIntegrationTest { | |||
every { edit() } returns sharedPreferencesEditor | |||
} | |||
eTagManager = ETagManager(sharedPreferences) | |||
signingManager = SigningManager(SignatureVerificationMode.Disabled, appConfig, apiKey()) | |||
signingManager = spyk(SigningManager(signatureVerificationMode, appConfig, apiKey())) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since there is no way to know that the offerings/product-entitlement mapping calls were verified or not
I checked that by using the "fake invalid signature" thing. Did you add a way to do that in Android too?
common/src/test/java/com/revenuecat/purchases/common/HTTPClientVerificationTest.kt
Outdated
Show resolved
Hide resolved
common/src/test/java/com/revenuecat/purchases/common/networking/EndpointTest.kt
Outdated
Show resolved
Hide resolved
} | ||
|
||
@Test | ||
fun `needsNonceToPerformSigning is true for expected values`() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These tests are great.
common/src/main/java/com/revenuecat/purchases/common/networking/Endpoint.kt
Outdated
Show resolved
Hide resolved
@@ -33,6 +33,22 @@ sealed class Endpoint(val pathTemplate: String, val name: String) { | |||
} | |||
|
|||
val supportsSignatureValidation: Boolean |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this isn't used now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in iOS: RevenueCat/purchases-ios#2752
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also this isn't used now?
It's used in the signing manager:
Line 23 in ef34062
return endpoint.supportsSignatureValidation && signatureVerificationMode.shouldVerify |
Will merge this and rerun the backend integration tests there once the backend is deployed. |
…oints with no signature (#2752) Equivalent to RevenueCat/purchases-android#1119
Description
This adds support for static endpoint signing. Currently, that would be the offerings and product-entitlement mapping endpoints.