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

Feature/inject receipt validator #126

Merged
merged 4 commits into from
Jan 14, 2017

Conversation

daveluong
Copy link
Contributor

@daveluong daveluong commented Jan 12, 2017

Description

This PR serves as ground work to a patch to security issue where this framework calls Apple's receipt validation endpoints directly which is susceptive to MITM attack whereby attacker can spoof the receipt validation.

This PR also enables framework users to inject their own custom receipt validator. There are 3 scenarios where this is useful:

  • Framework users who want to implement server-to-server receipt validation (their own backend - Apple's validation service)

  • Framework users who want to handle validation on their own backend

  • Client-side receipt validation implementation

Code related changes

  • New ReceiptValidator protocol. Custom receipt validator should conform to this protocol
public protocol ReceiptValidator {
	func validate(receipt: String, password autoRenewPassword: String?, completion: @escaping (VerifyReceiptResult) -> Void)
}
  • Modified signature of verifyReceipt function to let user to inject custom receipt validator object

  • Extract existing validation code to AppleReceiptValidator that conforms to ReceiptValidator

  • Updated examples to use AppleReceiptValidator, this should be served only for demonstration purpose, shouldn't use this validator for production code

@bizz84
Copy link
Owner

bizz84 commented Jan 13, 2017

Thank you for this PR! I'll review it this weekend.

@bizz84 bizz84 merged commit 4fce54d into bizz84:master Jan 14, 2017
@bizz84
Copy link
Owner

bizz84 commented Jan 14, 2017

Great work, thanks! Now available on pod version 0.6.2: 🚀

https://github.com/bizz84/SwiftyStoreKit/releases/tag/0.6.2

@daveluong
Copy link
Contributor Author

Thank you so much! Great and useful library!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants