Loopback-next: Loopback4 Authentication

Created on 27 May 2020  路  23Comments  路  Source: strongloop/loopback-next

Suggestion


I know you already create docs for adding the Authentication in loopback4 using the shopping example. But for developers to understand is tough (for me also previously as there are some bugs into also- in docs.)

Use Cases

So, I create a repo with the Readme file where a complete processor and steps are mentions of implementing the Authentication is given. [Repo link: https://github.com/HrithikMittal/Loopback4-auth ]
I just give a bit of advice, If you can add the repo into yours or just add Readme would be beneficial for other developers.

Examples

Authentication of User.

https://github.com/HrithikMittal/Loopback4-auth

Acceptance criteria

Docs feature

Most helpful comment

@HrithikMittal I appreciate that the lb4 shopping example is a steep learning curve compared to a guide. There are several ways to look at docs, some people prefer different approaches. Hopefully your guide can be reviewed and used to improve docs. Your proposal looks decent, let's see how it goes and as @madaky mentions there is still active development in progress so things can still change.

All 23 comments

I agree totally, I'm currently trying to add a simple user / login -> token into the API.
I'm fighting for 3 days, trying to make the tutorial in a loop + trying with the shopping example (that is not working) + passport example (that is not working too). It's so sad to see that the documentation is so hard to understand. When you go on the example for adding a JWT token authentification the page is soo long and messy, there is part of code referring to files that were made in the example but not mentioned, you need to read the doc and CTRL + F constantly in the app examples (that you can't run) (like figure out that there is a ./keys file in the shopping example).

@HrithikMittal thank you so much for this post that will probably help a lot of people in my case.
I hope the documentation will be updated regarding this point.

Same I also suffered a lot and that's why I create a new project with complete steps (just go through the readme). I hope it will help you.
@mathias22osterhagen22

Please bear in mind that examples like the lb4 shopping example app are constantly updated with new features. The example apps can fall out of sync with the documentation for features such as authentication. That being said, the lb4 shopping example should be a working copy that can referred to and reverse engineered into your own projects.

Extension @loopback/authentication-jwt, leverage off the burden from user to go from lots of manual work-offs. Just they need is small entries in their application.Yet this is under experimental release, but a good one to setup quick authentication.

@dougal83 I completely agree with you but the lb4 shopping example app is not that easy to understand and here I just give the Authentication and the steps in Readme are very easy to understand.

@HrithikMittal I appreciate that the lb4 shopping example is a steep learning curve compared to a guide. There are several ways to look at docs, some people prefer different approaches. Hopefully your guide can be reviewed and used to improve docs. Your proposal looks decent, let's see how it goes and as @madaky mentions there is still active development in progress so things can still change.

Hi everyone, there are gaps between the auth doc and auth modules, I am rewriting the doc to reflect the latest change. PRs coming soon.
Sorry for the confusion ^

Hi @jannyHou Please can you check this repo also I create a new one for the Authorization https://github.com/HrithikMittal/loopback4-authorization
Again I mention all the steps of how to do it. I hope it will be more beneficial for others to understand as there is a lot of confusion in official docs.

@HrithikMittal Thank you! ~For https://github.com/HrithikMittal/Loopback4-auth, I think it's an improvement of the jwt tutorial in shopping example.~ The jwt module in shopping example is created very early and unfortunately we didn't update it in time to reflect the latest change.

Now we have a much easier tutorial to get people on board with authentication using https://github.com/strongloop/loopback-next/tree/master/extensions/authentication-jwt and https://github.com/strongloop/loopback-next/tree/master/examples/todo-jwt, the documentation is in build.

And I have a plan to refactor the scattered auth docs in https://github.com/strongloop/loopback-next/issues/5294#issue-609624228, feedback is welcomed!

I see https://github.com/HrithikMittal/Loopback4-auth is a standalone module, I will make https://github.com/HrithikMittal/Loopback4-auth as the "Advanced tutorial for implement your own JWT auth module"

Thank you @jannyHou and please tell me where you make it as you mention in your comment.
Apart from this If you want me to change anything in this module folder or file or in Readme please let me know I will do it.
Please also check this issue https://github.com/strongloop/loopback-next/issues/5595 and
this also https://github.com/strongloop/loopback-next/issues/110 I would like to contribute more to this project and make things easier for developers to understand.

Hi @HrithikMittal and everyone gets blocked by the authentication documentation. I started a refactor PR in https://github.com/strongloop/loopback-next/pull/5598, and there will be more coming in the next few days to create the new skeleton of the auth doc.

I understand the concern and frustration of seeing the out-of-date but before I create the new layout, it's hard to tell community the criteria of follow-up stories :(

Please also check this issue #5595 and
this also #110 I would like to contribute more to this project and make things easier for developers to understand.

馃憤 馃憤 We really appreciate your help, and I will let you know the plan details asap when I finish ^

An update:

A few PRs are created to re-structure the authentication doc:

Since https://github.com/strongloop/loopback-next/issues/5294 is used to track the new structure of doc. I would like to turn this story to be an improvement of the new doc. Updated the acceptance criteria as:

Add https://github.com/HrithikMittal/Loopback4-auth as an example tutorial after re-structing the authentiation doc in #5294

There are many good examples within this monorepo and from community. We will add them soon after https://github.com/strongloop/loopback-next/pull/5598 merged. And https://github.com/HrithikMittal/Loopback4-auth is definitely an outstanding one :)

thank you @jannyHou

The passport example should work after fixing https://github.com/strongloop/loopback-next/pull/5766.

Sorry @jannyHou but it is still not working I just follow these commands

lb4 example
> passport-login
cd loopback4-example-passport-login
npm install

image

@HrithikMittal It seems that you are requesting a package from npm that does not exist or is not published yet. See https://www.npmjs.com/package/@loopback/mock-oauth2-provider and it's only v0.1.0.

Although you can clone the loopback-next repo and use the change in the example, you may have to wait for @loopback/mock-oauth2-provider v0.1.1 to be published to use in your own project.

@dougal83 @HrithikMittal good catch, https://github.com/strongloop/loopback-next/pull/5855 next publish should have the right version.

@jannyHou, the 5 items you described https://github.com/strongloop/loopback-next/issues/5573#issuecomment-640990068 are done. Is this issue good to close? Thanks.

Hey, @dhmlau Can you tell me where you add it as an example.

Add https://github.com/HrithikMittal/Loopback4-auth as an example tutorial after re-structing the authentiation doc in #5294

@HrithikMittal, I didn't realize the acceptance criteria is different from the 5 items listed in https://github.com/strongloop/loopback-next/issues/5573#issuecomment-640990068. 馃様

@jannyHou, if we're going to add https://github.com/HrithikMittal/Loopback4-auth as the example tutorial, since it's coming from @HrithikMittal, I think it might be better for @HrithikMittal to submit a PR to add the example for the authorship. It will include (can be separate PRs):

  1. add the app under examples folder.
  2. add it to the Examples page: https://loopback.io/doc/en/lb4/Examples.html.
  3. update the lb4 example cli to include this example

@jannyHou @HrithikMittal, WDYT?

Okay @dhmlau I will create one PR for this.
Thanks

Closing this issue as https://github.com/strongloop/loopback-next/pull/5999 merged.

Now the example https://github.com/HrithikMittal/Loopback4-auth is listed on the overview page!

Other refactors mentioned in this issue are addressed in https://github.com/strongloop/loopback-next/issues/5294

Was this page helpful?
0 / 5 - 0 ratings