-
-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
feat: Add TOTP authentication adapter #8457
Conversation
I will reformat the title to use the proper commit message syntax. |
Thanks for opening this pull request! |
Codecov ReportPatch coverage:
Additional details and impacted files@@ Coverage Diff @@
## alpha #8457 +/- ##
==========================================
- Coverage 94.45% 94.40% -0.05%
==========================================
Files 184 185 +1
Lines 14635 14756 +121
==========================================
+ Hits 13823 13930 +107
- Misses 812 826 +14
☔ View full report in Codecov by Sentry. |
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.
Looks good! I think the new auth adapter provides so much versatility, it merits its own section in the docs to make it easier for developers to use; opened parse-community/docs#929.
Definitions check fails, is this check flaky?
Hi @mtrezza @dblythy i'm really asking my self maybe we need to start a mono repo for adapters, to avoid to add too many deps to parse-server. Then we will be able to move out all adapters and may be GraphQL. I think we need to avoid now to add new packages to parse-server, to avoid a big monolith ( slower to start, to test, more security updates and more)
I saw on the forum some users were interested in this new feature and especially in a MFA system (QR code + TOTP), since it is now an industry standard. |
That topic is discussed in #7293. The point you mention have been discussed extensively in the past. |
I know @mtrezza i'm just thinking here if until the mono repo is ready, new package installation on parse-server should be prevented ? I posted a comment with some feedback on my company monorepo usage: #7293 (comment) |
Since we don't have a timeline for migrating to mono and it's a more complex undertaking, we can't categorically prohibit the addition of new dependencies as it may block further development. But we should certainly - as we always try to - be critical of any dependency addition when reviewing PRs. |
@dblythy could you resolve the conflicts so we can merge? |
@dblythy Sidenote, based on the rest of the construction of the TOTP adapter (ignoring the type issues I mentioned), everything else looks good to me. My guess is it will take me roughly 1 hour (maybe less) to add TOTP support with tests in the Swift SDK. |
Question: For |
For context, the original REST API documentation doesn't strictly state the required type for In my experience, there are only a few places on the Parse Server that uses objects with mixed value types. In these particular cases, it makes it harder to design on the client side. My recommendation would be to retain type as much as possible, or else the server will eventually run into issues as it moves towards TypeScript and OpenAPI Support (#7744). |
We need to distinguish between a client SDK not supporting a specific auth adapter (and its response), and an actual breaking change that occurs if someone upgrades to a version of Parse Server that includes this PR. Also, if we have auth object types explicitly mentioned that are violated by this PR, it would probably also be a breaking change, but I haven't seen that in the docs. We strive to be consistent with types in preparation for TS support. If the adapter response can be modified in a follow-up PR to support more client SDKs without requiring a change on the SDK side - even better. However, a type inconsistency per se that doesn't break a client if the specific auth adapter is not used is not necessarily a breaking change and should not prevent a release. We have an established policy for how to deal with breaking changes should this response need to change in the future. It may even make sense to make the client SDKs more tolerant to handle different response types per auth adapter. Is that sense, is this an actual breaking change? |
In combination with #8457 (comment), I recommend searching the repo for
I posted that this is not the case here #8457 (comment), basically it will break a client even if the client doesn't have TOTP implemented based on:
|
Which client SDKs are currently affected? It may be a bug on the SDKs side, if they expect a type that is not explicitly documented anywhere. |
In addition to my fist paragraph in #8457 (comment) which includes documentation by original developers of Parse, look at one of the original SDKs, particularly all of the methods with |
@cbaker6 all of the current in built auth adapters return the |
Yes. if a custom adapter returns something other than a |
The server (with its adapters) is the authoritative entity and the SDKs need to adapt to it, not the other way around. If the adapter can be modified to return the same types as the other adapters, then that's great and the preferred option. If not, then some SDKs simply don't support the adapter, meaning, it can be a caveat of the adapter that just needs to be documented. @dblythy Is it reasonably possible to modify the adapter types? |
To me it sounds entirely plausible that a custom auth adapter would return other types, even though none of the in built adapters do, it could trip up developers implementing their own authentication adapters. Based on @cbaker6’s comments, it doesn’t seem like anyone using a version of Parse Swift has had this issue though. It’s easy enough to adapt this PR with using |
Sounds good to me. If possible we could add a test for adapters to return the restrictive, historic types. With a future release of Parse Server we should probably break this restriction up and make a PR in the client SDKs to support more auth adapters return types. |
This will work and be inline with the rest of the adapters. @dblythy did you see my question here? #8457 (comment)
Of course, you all can do whatever you want here as I'm not on the server team. Accepting an infinite type in something like |
You might have misunderstood, I'm not referring to Parse Server built supported, internal auth adapters, I'm referring to a developer implementing their own auth adapter, and returning custom types there. Should the server validate these types here? I’m thinking we should perhaps code a stronger auth policy to either prevent or allow custom developer defined auth adapters to require specific types |
I say yes, but it depends on how the server team proceeds. If a dev implements a custom auth and it puts a type that is not a |
Parse Server is about openness and versatility. If a developer has a use case in which they use only the REST API and custom auth adapter with custom types, I don't think the server should be prohibiting that. There is also no rule that every adapter that comes included with Parse Server is compatible with all existing client SDKs, just whatever caveats it has should be documented. I also don't think that supporting multiple types and having a variable response structure (per adapter) is out of the ordinary for an API or even "bad practice". It just needs to be properly implemented on the SDK side. |
@dblythy you may have answered #8457 (comment) somewhere in the thread, if so, my apologies for missing it, can you point me to the answer? Also, can you verify the return type of |
As far as I can tell, expiry doesn't ever make it to the client side, due to the
|
# [6.4.0-beta.1](6.3.0...6.4.0-beta.1) (2023-09-16) ### Bug Fixes * Parse Server option `fileUpload.fileExtensions` does not work with an array of extensions ([#8688](#8688)) ([6a4a00c](6a4a00c)) * Redis 4 does not reconnect after unhandled error ([#8706](#8706)) ([2b3d4e5](2b3d4e5)) * Remove config logging when launching Parse Server via CLI ([#8710](#8710)) ([ae68f0c](ae68f0c)) * Server does not start via CLI when `auth` option is set ([#8666](#8666)) ([4e2000b](4e2000b)) ### Features * Add conditional email verification via dynamic Parse Server options `verifyUserEmails`, `sendUserEmailVerification` that now accept functions ([#8425](#8425)) ([44acd6d](44acd6d)) * Add property `Parse.Server.version` to determine current version of Parse Server in Cloud Code ([#8670](#8670)) ([a9d376b](a9d376b)) * Add TOTP authentication adapter ([#8457](#8457)) ([cc079a4](cc079a4)) ### Performance Improvements * Improve performance of recursive pointer iterations ([#8741](#8741)) ([45a3ed0](45a3ed0))
🎉 This change has been released in version 6.4.0-beta.1 |
# [6.4.0-alpha.1](6.3.0...6.4.0-alpha.1) (2023-09-20) ### Bug Fixes * Parse Server option `fileUpload.fileExtensions` does not work with an array of extensions ([#8688](#8688)) ([6a4a00c](6a4a00c)) * Redis 4 does not reconnect after unhandled error ([#8706](#8706)) ([2b3d4e5](2b3d4e5)) * Remove config logging when launching Parse Server via CLI ([#8710](#8710)) ([ae68f0c](ae68f0c)) * Server does not start via CLI when `auth` option is set ([#8666](#8666)) ([4e2000b](4e2000b)) ### Features * Add conditional email verification via dynamic Parse Server options `verifyUserEmails`, `sendUserEmailVerification` that now accept functions ([#8425](#8425)) ([44acd6d](44acd6d)) * Add context to Cloud Code Triggers `beforeLogin` and `afterLogin` ([#8724](#8724)) ([a9c34ef](a9c34ef)) * Add property `Parse.Server.version` to determine current version of Parse Server in Cloud Code ([#8670](#8670)) ([a9d376b](a9d376b)) * Add TOTP authentication adapter ([#8457](#8457)) ([cc079a4](cc079a4)) ### Performance Improvements * Improve performance of recursive pointer iterations ([#8741](#8741)) ([45a3ed0](45a3ed0))
🎉 This change has been released in version 6.4.0-alpha.1 |
# [6.4.0](6.3.1...6.4.0) (2023-11-16) ### Bug Fixes * Parse Server option `fileUpload.fileExtensions` does not work with an array of extensions ([#8688](#8688)) ([6a4a00c](6a4a00c)) * Redis 4 does not reconnect after unhandled error ([#8706](#8706)) ([2b3d4e5](2b3d4e5)) * Remove config logging when launching Parse Server via CLI ([#8710](#8710)) ([ae68f0c](ae68f0c)) * Server does not start via CLI when `auth` option is set ([#8666](#8666)) ([4e2000b](4e2000b)) ### Features * Add conditional email verification via dynamic Parse Server options `verifyUserEmails`, `sendUserEmailVerification` that now accept functions ([#8425](#8425)) ([44acd6d](44acd6d)) * Add property `Parse.Server.version` to determine current version of Parse Server in Cloud Code ([#8670](#8670)) ([a9d376b](a9d376b)) * Add TOTP authentication adapter ([#8457](#8457)) ([cc079a4](cc079a4)) ### Performance Improvements * Improve performance of recursive pointer iterations ([#8741](#8741)) ([45a3ed0](45a3ed0))
🎉 This change has been released in version 6.4.0 |
Pull Request
Issue
Closes: #8441
Approach
Creates a OTP auth adapter, for both SMS based OTP and time based OTP (TOTP)
Tasks