-
Notifications
You must be signed in to change notification settings - Fork 175
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
examples: add gatekeeper-auth example. #1963
Conversation
scope "/gatekeeper" do | ||
pipe_through :gatekeeper | ||
|
||
post "/:table", Electric.Phoenix.Gateway.Plug, client: &Authenticator.client/0 |
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.
@magnetised the client
syntax / concept isn't the most obvious here. It's great that we can technically pass in an Authenticator
via the client option. However the reason to be using a "client" in this context isn't super obvious. I'd much rather write e.g.:
post "/:table", Electric.Phoenix.Gateway.Plug, authenticator: {MyAuthenticator, []}
Or even just the function that generates the auth headers:
post "/:table", Electric.Phoenix.Gateway.Plug, auth_headers: &MyAuthenticator.authenticate_shape/2
Following the thought, that Authenticator.authenticate_shape/2
function gets the shape
and a config
options keyword list. It doesn't get the conn
. Which, when generating an auth token, might be useful context, for example to put a user_id
in the token, etc.
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.
good points.
✅ Deploy Preview for electric-next ready!
To edit notification comments on pull requests, go to your Netlify site configuration. |
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.
I still have to go through the actual code but the readme is 🔥
Concise, clear, and to the point. Great job! 🥇
586fbda
to
8c20344
Compare
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.
Excellent
Examples |
See https://github.com/electric-sql/electric/tree/thruflo/gatekeeper-auth-example/examples/gatekeeper-auth -- the example folder and subfolders all have READMEs.
I haven't yet updated the auth guide. I suspect it's best to merge this and update the guide in a separate PR.