-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
The First Scenario: Authenticated orders (a minimal authentication) #1998
Comments
Originated from #1035 (comment) Acceptance Criteria
After this task is done, we should be able to support these APIs: See @loopback/authentication as inspiration. |
Hi @raymondfeng @bajtos I plan to work on this story while realize PR loopbackio/loopback4-example-shopping#26 already covers the acceptance criteria as the created custom authentication action Are we good to close this task?
And then create another story for ^ |
At the moment, export class UserOrderController {
// ...
async createOrder(
@param.path.string('userId') userId: string,
@requestBody() order: Order,
): Promise<Order> {
if (userId !== order.userId) {
throw new HttpErrors.BadRequest(
`User id does not match: ${userId} !== ${order.userId}`,
);
}
delete order.userId;
return await this.userRepo.orders(userId).create(order);
}
} I find it ugly for an application to have authentication in place and yet allow callers to make orders for other users, it's kind of a tech debt for an example app like the shopping app. In my plan outlined in #1035 (comment), the goal of the step The First Scenario: Authenticated orders (a minimal authentication) was to improve this part of our example. The part about improving
I would like to see both these changes happen before we move on to next steps on this journey. Planning wise, I am not sure what exactly was considered as the scope for this milestone and what not. Personally, I'd prefer to keep this story open until all changes described at the top are finished. However, I see that the acceptance criteria in #1998 (comment) describe a smaller scope, so maybe it's ok to create new GitHub stories for the remaining changes and close this one as done. I'll leave it up to you @jannyHou and @dhmlau to decide. For me, the most important part is to ensure all we implement all changes needed to make authentication easy to use and to make the example app to a high-quality reference implementation. |
The discussion here illustrates the difference between authentication and authorization. For the |
Discussed with @raymondfeng @jannyHou @emonddr:
@jannyHou , could you please verify? Thanks. |
Acceptance Criteria
|
Yeap /users/me works today, but not works on other endpoints, such as orders |
Related PR: loopbackio/loopback4-example-shopping#71 |
Closing per the discussion in https://github.com/strongloop/loopback-next/pull/4144/files#r347996012 |
Description
Step 3 from #1035 (comment).
Rework
UserOrderController
to obtain the customer id from the request (the access token provided by the client) instead of a URL-path parameter.For example, we can remove
/users/{userId}
prefix from all endpoints to end up with the following API:POST /orders
creates a new orderGET /orders
returns all orders of the current userPATCH /orders?where=
to update some of the orders of the current user. I think this endpoint does not make sense in a Shopping app and should be eventually removed.DELETE /orders?where=
to delete some of the orders of the current user. I think this endpoint should be eventually removed, because orders are never deleted, they can be only closed (e.g. as cancelled).Existing REST API exposed by
UserController
should remain unauthenticated (allowing anonymous access).The goal of this story is to leverage
@loopback/authentication
to implement this feature and improve@loopback/authentication
along the way as needed.Previous step: #1997
Next step: #1999
The text was updated successfully, but these errors were encountered: