parse-community / Parse-Swift

The Swift SDK for Parse Platform (iOS, macOS, watchOS, tvOS, Linux, Android, Windows)
https://parseplatform.org
MIT License
304 stars 69 forks source link

Adding Support for more 3rd Party Authentication SDK's #55

Open cbaker6 opened 3 years ago

cbaker6 commented 3 years ago

New Feature / Enhancement Checklist

Current Limitation

Parse-Swift currently supports Anonymous authentication (ParseAnonymous) and Apple authentication (see all adapters below).

Microsoft Graph, Instagram, and any Parse Server supported authentication method do work, but they currently don't have helper methods to connect to them as easily as using ParseApple.

Populating authData directly requires knowing the correct key/values for the respective adapter and can quickly lead to mistakes in code during login, linking, etc.

Feature / Enhancement Description

To make the process simpler, developers can easily add support for additional 3rd party authentication methods by using ParseGoogle as a template.

Example Use Case

We are encouraging developers to open PR's (see the contributors guide) to add missing authentication methods by following the process below:

  1. Create a new file inside the 3rd Party folder and name it ParseNAME.swift, for example ParseFacebook .
  2. Copy the code from ParseGoogle.swift, ParseGoogle+async.swift, ParseGoogle+combine.swift into the new respective adapter files you are creating.
  3. Refactor by: a) Find/replace Google -> Name, b) Find/replace google -> name
  4. Modify/tailor the helper methods to work with the specific SDK. This will require modifying AuthenticationKeys in the file.
  5. Add any additional methods that may be needed to verify inputs or simplify passing in values to the method.
  6. Update documentation/comments in the code to reflect the new adapter
  7. Copy/modify the ParseGoogleTests.swift, ParseGoogleCombineTests.swift file to add the respective test cases.
  8. Refactor test files by: a) Find/replace Google -> Name, b) Find/replace google -> name
  9. Submit your pull request for review

Note that the dependency of the the respective framework, i.e. import FBSDKCoreKit shouldn't be part of the PR as Parse-Swift is dependency free. Instead the implementation should just ensure the necessary AuthenticationKeys are captured to properly authenticate the respective framework with a Parse Server. The developer using the respective authentication method is responsible for adding any dependencies for their app. This lets the developer manage and use any version of any authentication SDK's they want, they simply need to specify the required keys that the Parse Server requires.

If you need help, feel free to ask questions here or in your added PR.

Potential adapters (checked one’s are already implemented in Parse-Swift):

Alternatives / Workarounds

To authenticate without helper methods, you can use the following available on any ParseUser: https://github.com/parse-community/Parse-Swift/blob/86d4eb74233838d15e78ecf8e9de72b341652440/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication.swift#L155-L301

and here: https://github.com/parse-community/Parse-Swift/blob/fb61b785de042ed2ae6efa5895d25d79ef2e9e93/Sources/ParseSwift/Authentication/Protocols/ParseAuthentication%2Bcombine.swift#L36-L94

3rd Party References

cbaker6 commented 3 years ago

To see an example PR following this process, look through the files added in #79 which added ParseLDAP or #97 which added ParseFacebook and ParseTwitter.

parse-github-assistant[bot] commented 2 years ago

Thanks for opening this issue!