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
Update Clerk auth provider logic #4443
Conversation
978b7bd
to
acab11e
Compare
acab11e
to
adf6e76
Compare
Thank you for this @devchampian I'm looping in @dthyresson to help get this to the finish line (DT, please pass along if/as needed). Question on my end:
|
Yes, it is. The only exception is the small fix included in this PR around the CLI auth setup script replacing the Redwood
The previous implementation is still supported by Clerk. The change to use the
So I did confirm it was working locally by following your contributing documentation on testing the CLI. If you pull down this branch, run Caveat: I wasn't able to get the
The only change needed in the docs would be to update We are likely going to be making a more substantial change to the Clerk integration with our Auth v2 update in the future. I think at that point, we can also revisit the docs to make sure everything is up-to-date with all the latest goodness. Thank you @thedavidprice for taking a look at this! |
I also just posted this tutorial based on the official Redwood one, but adding Clerk auth. The corresponding codebase is here if you want to validate the changes with a sample application. |
This is excellent! Reading now. Thank you! |
Thank you for answering my questions @devchampian
^^ this feels like the most important callout to make in the Release Notes @dthyresson once reviewed and approved, can you help me stay on top of ToDos related to copy and docs? |
Testing in GitPod now. Todo:
|
@devchampian Any chance when all integrated RedwoodJS could get a shout out here, too? |
Also, I wish (and maybe will add in future) that setup created a component for the Clerk UserButton to make sign up even easier:
And setup to somehow inject
within That would make setup rather slick. |
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.
@dthyresson Awesome, thank you! And absolutely we can add a RedwoodJS shoutout. 😄 This was just a minor update, but as previously discussed, we would like to upgrade the integration to our Auth v2 so I think at that time we can also do a docs refresh. I know Redwood has authentication built-in with dbAuth but it's great that it offers the flexibility to swap different providers for those folks who don't want to manage it themselves. Completely agree with you about the |
For types, it might be this:
Where type needs to include Edit: No, sorry. That's already in
Ok will have to look more closely. |
Not yet, but I know in v2 Redwood would like to make the setups more sophisticated and customizable, so for v1 I think the guides and tutorials work (but improve soon). Honestly, I got the test project up and running in 2-3 minutes really. |
Do you think that would be possible in the next 3-4 weeks? Edit: See #4459 (comment) for an update. |
Dismissing review as I'd like to update the AuthProvider types so no TS warnings.
I think that casting as const ClerkAuthConsumer = withClerk(({ children, clerk }) => {
return React.cloneElement(children as React.ReactElement<any>, { client: clerk })
}) |
Thanks, all! @dthyresson @devchampian Could either of you help to make sure the Redwood Auth Doc is updated to match this PR? See: |
@devchampian Is that note for the Docs? I.e. this: |
@thedavidprice Actually for the context of wherever @dthyresson took that screenshot. But yes, the docs can be updated there as well. |
@dthyresson Since I don't have context, could you help here with the final two things:
|
Except for TS, then need a slight change to: const ClerkAuthConsumer = withClerk(({ children, clerk }) => {
return React.cloneElement(children as React.ReactElement<any>, { client: clerk })
}) |
This PR includes 3 updates across 3 files:
auth/providers/clerk.js
- Simplified Clerk integration using the withClerk HOC. Explicitclient
andrender
props are no longer necessary.auth/templates/clerk.auth.js.template
- Added Clerk auth template. Previously the base template was being used. The standard template was updated in the tutorial repo (includes the use oflogger
and underscore prefix on unused variables) so that same one was copied over for Clerk.auth/auth.js
- The<AuthProvider />
in the Redwood tutorial was recently updated to remove theclient
prop with the introduction ofdbAuth
. This causes theyarn rw setup auth <provider> --force
script to fail in replacing the auth provider. This is because the regex is looking for aclient
prop which no longer exists. The updated regex pattern works regardless whether theclient
prop is set or not.The first two changes are specific to the Clerk integration. Only the third change affects the core auth setup logic.