-
Notifications
You must be signed in to change notification settings - Fork 2.2k
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
Move accounts plugin to Node app and better split accounts from users/IDP #5693
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Signed-off-by: Eric Dobbertin <[email protected]>
Signed-off-by: Eric Dobbertin <[email protected]>
Signed-off-by: Eric Dobbertin <[email protected]>
Signed-off-by: Eric Dobbertin <[email protected]>
Signed-off-by: Eric Dobbertin <[email protected]>
Signed-off-by: Eric Dobbertin <[email protected]>
Signed-off-by: Eric Dobbertin <[email protected]>
Signed-off-by: Eric Dobbertin <[email protected]>
Signed-off-by: Eric Dobbertin <[email protected]>
kieckhafer
reviewed
Oct 8, 2019
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.
Code looks mostly good, just a few import updates.
Testing functionality now.
imports/node-app/core-services/account/mutations/sendResetAccountPasswordEmail.js
Outdated
Show resolved
Hide resolved
imports/node-app/core-services/account/util/sendVerificationEmail.js
Outdated
Show resolved
Hide resolved
Signed-off-by: Eric Dobbertin <[email protected]> Co-Authored-By: Erik Kieckhafer <[email protected]>
Made suggested changes |
Signed-off-by: Eric Dobbertin <[email protected]>
kieckhafer
approved these changes
Oct 8, 2019
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.
👍 Works as expected, good to merge once CI passes.
Merged
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #5588
Resolves #5213
Impact: minor
Type: refactor
Changes
core-services
foldercreateUser
into the account plugin. It's still relying on Meteor, but that's OK until we split the apps.New Middleware Pattern
Plugins can register Express middleware using
registerPlugin
:For now, only "graphql" route is supported, and the following stages are supported in this order:
first
before-authenticate
authenticate
before-response
An
authenticate
middleware function should do something like look up the user by the Authorization header, and either setrequest.user
or send a 401 response if the token is invalid. It should not require a token. This is what the built-inaccount
service now does.The
first
middleware stage can be used for loggers or anything else that needs to be first in the middleware list.before-response
middleware will have the user available if there is one, and is called before the Apollo GraphQL middleware.A middleware function is passed
context
and must return the Express middleware handler function, which must callnext()
or send a response.Auth functions
Plugins can also define auth-related functions when calling
registerPlugin
. The built-in accounts service does this.These are all functions that are called on every request, when adding request-specific properties to
context
.accountByUserId(context, userId)
: Must return an account for the user ID, if one can be foundgetHasPermissionFunctionForUser(context)
: Must return a function that matches thecontext.userHasPermission
signature and returnstrue
orfalse
. This function can assumecontext.user
/context.account
is the user/account to check.getShopsUserHasPermissionForFunctionForUser(context)
: Must return a function that matches thecontext.shopsUserHasPermissionFor
signature and returns an array of shop IDs. This function can assumecontext.user
/context.account
is the user/account to check.Testing