You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In doing so, I have some suggestions for the custom auth setup.
Motivation
Making custom auth easier.
Detailed proposal
Give the custom auth setup command a name to generate named auth files rather than just "customAuth". This would be just like creating a Page or a Cell.
Why?
You may implement several custom auth providers. You don't want to reorganize and rename files.
yarn rw setup auth custom Md5Auth
Place in a named directory so can keep types and helpers (like localStorage helpers) neat and tidy.
/ <namedAuth>
- index.ts
- types.ts
Split up types from main auth into types. Just easier to read.
dthyresson
changed the title
[RFC]: Thought on Custom Auth Setup and Ideas to Improve
[RFC]: Thoughts on Custom Auth Setup and Ideas to Improve
Nov 16, 2022
Give the custom auth setup command a name to generate named auth files
Sounds great. Let's do this!
Place in a named directory
Split up types from main auth into types
The auth.ts file should just be where you import your custom client.
Setup should stub out a custom authDecoder
I worry all of this (2-5) will just make it feel overwhelming and too much boilerplate with so many new files, all with just some dummy code in them. I realize what you're suggesting is probably where many implementations will end up, but it might be better to let the user figure that out on their own.
UI
I mentioned reusing the dbAuth components you get by running rw g dbAuth. You said that gave you too much, so you had to remove a lot of it.
If you had written something production ready, would you still have had to remove as much? Or would most of it have been useful in that case?
and/or
Do you think we could write something smaller/simpler that's generic enough for the dbAuth generator to also use (like the scaffold generator uses the sdl generator under the hood)
Summary
I just completed an office hours example to implement a contrived custom auth example here: https://github.com/redwoodjs/redwood-office-hours/tree/main/2022-11-13-custom-md5-auth
In doing so, I have some suggestions for the custom auth setup.
Motivation
Making custom auth easier.
Detailed proposal
Give the custom auth setup command a name to generate named auth files rather than just "customAuth". This would be just like creating a Page or a Cell.
Why?
You may implement several custom auth providers. You don't want to reorganize and rename files.
Place in a named directory so can keep types and helpers (like localStorage helpers) neat and tidy.
Split up types from main auth into types. Just easier to read.
The
auth.ts
file should just be:where you import your custom client.
Setup should stub out a custom authDecoder and import that in the GraphQLHandler
It can be simply
And then stub out a named decoder as well
This way you have a general decoder a specific decoders.
This can make testing easier and also let you implement multiple decoders easier since it detects the type and uses the decoder it needs.
UI
90% of the time to create this custom auth example was in the UI setup for login, signup and profile widgets.
Perhaps the web setup can also copy over pre-made UI widgets?
Notes on Setup Netlify Auth
have to find and remove fro
App.js
import { AuthProvider } from '@redwoodjs/auth'
Have to replace all
with
Are you interested in working on this?
The text was updated successfully, but these errors were encountered: