-
Notifications
You must be signed in to change notification settings - Fork 189
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
Add auth middleware to Users service #2116
Merged
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
humphd
added
area: microservices
area: satellite
Issues related to the Satellite microservice project
type: security
Security concerns
labels
Apr 10, 2021
humphd
force-pushed
the
users-auth-middleware
branch
from
April 11, 2021 15:28
8ac5e29
to
13df267
Compare
Getting these tests to pass was more challenging than I'd expected, and has resulted in me having to fix a bunch of things in our docker setup and jest configs:
|
PedroFonsecaDEV
previously approved these changes
Apr 11, 2021
birtony
previously approved these changes
Apr 12, 2021
HyperTHD
reviewed
Apr 12, 2021
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. A few stuff and some questions
manekenpix
previously approved these changes
Apr 13, 2021
humphd
dismissed stale reviews from manekenpix, birtony, and PedroFonsecaDEV
via
April 13, 2021 13:52
1c28ee3
humphd
force-pushed
the
users-auth-middleware
branch
from
April 13, 2021 13:52
baeb023
to
1c28ee3
Compare
I need to fix this in a follow-up. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
area: microservices
area: satellite
Issues related to the Satellite microservice project
type: security
Security concerns
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.
This adds authentication (makes sure the user has a valid JWT token) and authorization (makes sure their token matches what we expect per route) middleware from Satellite to the Users service. It depends on DevelopingSpace/satellite#12 for some changes to the
isAuthorized()
middleware in Satellite.I'm adding middleware to all of the routes, but it's different in each case:
GET /
this can be done only by an admin or another microservice (e.g., Parser service). A regular user can't request this, nor can an anonymous, unauthenticated user.GET /:id
this can be done by the user who owns the data (e.g., I can request my own data), or by an admin or another microservice. A user can't request someone else's data, nor can an anonymous, unauthenticated user.POST /:id
this can be done by the user who owns the data (e.g., I can register my own data), or by an admin or another microservice. A user can't register someone else's data, nor can an anonymous, unauthenticated user.PUT /:id
this can be done by the user who owns the data (e.g., I can update my own data), or by an admin or another microservice. A user can't update someone else's data, nor can an anonymous, unauthenticated user.DELETE /:id
this can be done by the user who owns the data (e.g., I can delete my own data), or by an admin or another microservice. A user can't delete someone else's data, nor can an anonymous, unauthenticated user.I haven't written pure e2e tests here, which would also test things like trying to hit the various routes as different users. That would require the tests to be updated to full e2e tests first, so we'll have to come back to this.
A note about Satellite's middleware: a route must call
isAuthenticated()
beforeisAuthorized()
, since the latter uses the parsed token created by the former.The tests are going to fail until the Satellite fix is included.