Skip to content

Trusted Entitlements: stable#1105

Merged
tonidero merged 3 commits into
mainfrom
re-enable-verification
Jul 7, 2023
Merged

Trusted Entitlements: stable#1105
tonidero merged 3 commits into
mainfrom
re-enable-verification

Conversation

@NachoSoto

@NachoSoto NachoSoto commented Jun 27, 2023

Copy link
Copy Markdown
Contributor

This PR brings Trusted entitlements to stable and to java.

Trusted entitlements

This new feature prevents MitM attacks between the SDK and the RevenueCat server.
With verification enabled, the SDK ensures that the response created by the server was not modified by a third-party, and the entitlements received are exactly what was sent.
This is 100% opt-in. EntitlementInfos have a new VerificationResult property, which will indicate the validity of the responses when this feature is enabled.

fun configureRevenueCat() {
    val configuration = PurchasesConfiguration.Builder(context, apiKey)
        .entitlementVerificationMode(EntitlementVerificationMode.INFORMATIONAL)
        .build()
    Purchases.configure(configuration)
}

@NachoSoto NachoSoto added the pr:feat A new feature label Jun 27, 2023
@NachoSoto NachoSoto requested a review from a team June 27, 2023 22:02

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be the final API, so it can support ENFORCED when we re-add that, and so that it provides a consistent API for the hybrids. Thoughts @tonidero?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, In Android, I changed the parameter to a boolean since it kinda made more sense to me that, for this function that enabled 2 features to be a boolean instead of an EntitlementVerificationMode which doesn't have anything to do with diagnostics. I do agree that for the final release, if we separate both features, passing an enum like this to configure trusted entitlements makes the most sense. Happy to chat more about this though! cc @aboedo In case you have any thoughts.

Another question is, do we want to tie diagnostics to trusted entitlements for the final release? IMO, I mostly would like these features tied only while they are on beta so we can be more confident about it until we release it fully. I would split them after that.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh yeah that makes sense, even simpler.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This probably needs a test.

@tonidero

tonidero commented Jul 6, 2023

Copy link
Copy Markdown
Contributor

@NachoSoto I'm taking over this PR! Lmk if you had anything else planned here

@tonidero tonidero force-pushed the re-enable-verification branch from 960fbcf to 1672fde Compare July 6, 2023 09:05

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I kept the existing experimental method but deprecated, In case anyone is using it since it's pretty easy to keep. We can remove it on the next major.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This will be the way to enable entitlement verification.

@tonidero tonidero changed the title [WIP] Trusted Entitlements: re-enable verification API Trusted Entitlements: stable Jul 6, 2023
@tonidero tonidero added the HOLD label Jul 6, 2023
@NachoSoto

Copy link
Copy Markdown
Contributor Author

Awesome. We'll just need to update RevenueCat/purchases-hybrid-common#451

@tonidero tonidero force-pushed the re-enable-verification branch from 42240b8 to c6603dd Compare July 7, 2023 07:55
@tonidero tonidero changed the base branch from main to not-decode-encoded-url July 7, 2023 07:56
@tonidero tonidero marked this pull request as ready for review July 7, 2023 08:01
@tonidero tonidero requested a review from a team July 7, 2023 08:01
@tonidero tonidero removed the HOLD label Jul 7, 2023
@tonidero

tonidero commented Jul 7, 2023

Copy link
Copy Markdown
Contributor

Awesome. We'll just need to update RevenueCat/purchases-hybrid-common#451

I updated that PR to reflect the new name

Base automatically changed from not-decode-encoded-url to new-trusted-entitlements-signature-format July 7, 2023 11:17
@tonidero tonidero force-pushed the re-enable-verification branch from c6603dd to 31f10f1 Compare July 7, 2023 13:47

@NachoSoto NachoSoto left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ship it

Base automatically changed from new-trusted-entitlements-signature-format to main July 7, 2023 15:03
@tonidero tonidero force-pushed the re-enable-verification branch from 31f10f1 to affe47d Compare July 7, 2023 15:06
@codecov

codecov Bot commented Jul 7, 2023

Copy link
Copy Markdown

Codecov Report

Merging #1105 (31f10f1) into main (982d3f8) will decrease coverage by 0.36%.
The diff coverage is 70.96%.

❗ Current head 31f10f1 differs from pull request most recent head affe47d. Consider uploading reports for the commit affe47d to get more accurate results

@@            Coverage Diff             @@
##             main    #1105      +/-   ##
==========================================
- Coverage   85.60%   85.25%   -0.36%     
==========================================
  Files         175      175              
  Lines        6038     6098      +60     
  Branches      875      893      +18     
==========================================
+ Hits         5169     5199      +30     
- Misses        528      555      +27     
- Partials      341      344       +3     
Impacted Files Coverage Δ
...kotlin/com/revenuecat/purchases/EntitlementInfo.kt 65.97% <ø> (-0.35%) ⬇️
...otlin/com/revenuecat/purchases/EntitlementInfos.kt 81.25% <ø> (-1.11%) ⬇️
...evenuecat/purchases/EntitlementVerificationMode.kt 75.00% <0.00%> (-25.00%) ⬇️
.../main/kotlin/com/revenuecat/purchases/Purchases.kt 81.29% <ø> (ø)
...revenuecat/purchases/common/caching/DeviceCache.kt 95.86% <ø> (ø)
...m/revenuecat/purchases/identity/IdentityManager.kt 97.43% <ø> (ø)
...com/revenuecat/purchases/strings/NetworkStrings.kt 0.00% <ø> (ø)
...s/common/verification/SignatureVerificationMode.kt 80.95% <66.66%> (-13.50%) ⬇️
...at/purchases/common/verification/SigningManager.kt 74.41% <68.11%> (-25.59%) ⬇️
...enuecat/purchases/common/networking/ETagManager.kt 95.77% <83.33%> (-1.25%) ⬇️
... and 3 more

@tonidero tonidero enabled auto-merge (squash) July 7, 2023 15:07
@tonidero tonidero merged commit 83d41dc into main Jul 7, 2023
@tonidero tonidero deleted the re-enable-verification branch July 7, 2023 15:15
tonidero added a commit that referenced this pull request Jul 12, 2023
**This is an automatic release.**

### New Features
* `Trusted Entitlements`: made API stable (#1105) via NachoSoto
(@NachoSoto)

This new feature prevents MitM attacks between the SDK and the
RevenueCat server.
With verification enabled, the SDK ensures that the response created by
the server was not modified by a third-party, and the entitlements
received are exactly what was sent.
This is 100% opt-in. `EntitlementInfos` have a new `VerificationResult`
property, which will indicate the validity of the responses when this
feature is enabled.

```kotlin
fun configureRevenueCat() {
    val configuration = PurchasesConfiguration.Builder(context, apiKey)
        .entitlementVerificationMode(EntitlementVerificationMode.INFORMATIONAL)
        .build()
    Purchases.configure(configuration)
}
```
### Experimental features
* Add await offerings (#1096) via Cesar de la Vega (@vegaro)
### Bugfixes
* Fix issue updating customer info on app open (#1128) via Toni Rico
(@tonidero)
### Dependency Updates
* Bump fastlane-plugin-revenuecat_internal from `13773d2` to `b2108fb`
(#1095) via dependabot[bot] (@dependabot[bot])
### Other Changes
* [PurchaseTester] Add option to purchase an arbitrary product id
(#1099) via Mark Villacampa (@MarkVillacampa)
* Fix release path after module refactor (#1129) via Toni Rico
(@tonidero)
* Fix load shedder integration tests (#1125) via Toni Rico (@tonidero)
* Trusted entitlements: New trusted entitlements signature format
(#1117) via Toni Rico (@tonidero)
* Fix integration tests and change to a different project (#1123) via
Toni Rico (@tonidero)
* Move files into src/main/kotlin (#1122) via Cesar de la Vega (@vegaro)
* Remove public module (#1113) via Cesar de la Vega (@vegaro)
* Remove common module (#1106) via Cesar de la Vega (@vegaro)
* Fix flaky integration tests: Wait for coroutines to finish before
continuing (#1120) via Toni Rico (@tonidero)
* Move amazon module into purchases (#1112) via Cesar de la Vega
(@vegaro)
* Trusted entitlements: Add IntermediateSignatureHelper to handle
intermediate signature verification process (#1110) via Toni Rico
(@tonidero)
* Trusted entitlements: Add Signature type to process new signature
response format (#1109) via Toni Rico (@tonidero)
* [EXTERNAL] Add `awaitCustomerInfo` / coroutines tests to
`TrustedEntitlementsInformationalModeIntegrationTest` (#1077) via
@pablo-guardiola (#1107) via Toni Rico (@tonidero)
* Remove feature:google module (#1104) via Cesar de la Vega (@vegaro)
* Remove identity module (#1103) via Cesar de la Vega (@vegaro)
* Remove subscriber attributes module (#1102) via Cesar de la Vega
(@vegaro)
* Delete utils module (#1098) via Cesar de la Vega (@vegaro)
* Remove strings module (#1097) via Cesar de la Vega (@vegaro)
* Update CHANGELOG.md to include external contribution (#1100) via Cesar
de la Vega (@vegaro)
* [EXTERNAL] Add missing `fetchPolicy` parameter to `awaitCustomerInfo`
API (#1086) via @pablo-guardiola (#1090) via Toni Rico (@tonidero)

---------

Co-authored-by: revenuecat-ops <ops@revenuecat.com>
Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
tonidero added a commit to RevenueCat/purchases-hybrid-common that referenced this pull request Nov 17, 2023
)

Depends on RevenueCat/purchases-ios#2621 and
RevenueCat/purchases-android#1105.

---------

Co-authored-by: Toni Rico <antonio.rico.diez@revenuecat.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pr:feat A new feature

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants