-
Notifications
You must be signed in to change notification settings - Fork 192
Basic authentication #118
Comments
Do you want to have the passwords encrypted with something like bcrypt or just plain text for now? |
For all of those getting ready for this. Read the comments on the cleanup commit first as to why some things have changed! 13b9f07 |
No need to encrypt the passwords. This is just a quick step before we do something else. |
👍 |
First question. I have this according to the tutorial on the hapi page :
I think server is the same as the this line in index.js : server = new Hapi.server(). |
Make a new plugin (like Version) and use the server object you get there |
I did make a new plugin. You mean something like this : exports.register = function (server, options, next) { |
yeah, you can use the server object you get there to register the Basic Auth strategy |
Sorry for all the references, I was messin up my rebases 😬 |
Second question. I rewrote index.js to this so it's register more then 1 plugin.
but on testing and running I see this error message : Error: Cannot find module 'Version' What did I have done wrong ? |
No need to make it so complex, just build on the existing code. You can pass an array of objects into |
No need to server.register([Version, Authentication], function (err) {
if (err) {
return next(err);
}
server.start(function (err) {
return next(err, server);
});
}); |
When I do what hussainanjr says I see this error message : Invalid plugin object - invalid or missing register function attributes property (1) |
@roelof1967 does your authentication plugin follow similar guidelines to version plugin ? |
Yes, my code so far can be found here : https://github.com/roelof1967/hueniversity |
and when I do npm start I see this error message :
|
@roelof1967 Hi, from what I see on your repo, your export.register.attributes object is empty and defined inside of the export.register instead of after it. |
Thanks, I changed it and now I see this error message : Timed out (2000ms) - starts server and returns hapi server object |
found it. It was a missing return next() on the new plugin. |
New problem : on this code : https://github.com/roelof1967/hueniversity/blob/master/test/authentication.js |
also solved. I have forgotten to do something when a user is valid, PR is already ready |
* Add hapi-auth-basic * Add private plugin * Closes outmoded#118
* Add hapi-auth-basic * Add private plugin * Closes outmoded#118
* Add hapi-auth-basic * Add private plugin * Closes outmoded#118
Life has been pretty busy lately (selling house, starting a few new projects) and as you can see this project (along with many others) suffered from it. I intent to finish reviewing assignment 4 this week and post one more assignment before taking a break for a bit. If anyone wants to take lead on this and write some more assignments (I am happy to review it and the expected responses to keep things consistent) please let me know. |
That is both great and sad to hear. I wish you all the success with the new projects and selling the house! I hope to see something cool again in the near future from you. As for hueniversity, it's sad because I really feel this is something really great and useful to learn from. If I had enough experience with node and hapi I would consider taking this up but I don't feel I'm the man for the job. I will give all my support for anyone who does take it. |
@hueniverse @AdriVanHoudt and community. I am willing to write assignments for hueniversity. Every learning objective described in the above link is illustrated in this project: The "glued" project has all the core components a hapijs web server should have except It would be fun to collaborate with the community and build a great tutorial and at the same time Additionally, hueniversity needs to continue because hapijs is the best node.js application framework in existence. However, it does not have the best documentation. So, this project has a lot of value to add to the community because it addresses the documentation need. So, let's keep this project going :-) What does everyone think? Note: I work too and am busy just like everyone else here. So, I hope this will really become a community / team effort :-) Let's try to share the load. |
@zoe-1 I really like the community approach and as I said, I'm willing to On Mon, 4 May 2015 19:28 rutaihwa [email protected] wrote:
|
I'm still new to JS world but I'm willing to participate as much as possible @zoe-1 @AdriVanHoudt 👍 |
@zoe-1 happy to move this project over to the hapijs org and add some maintainers. Should we give it a new name? |
@hueniverse I would suggest hapiuniversity as a new name |
Moving this under the hapijs org makes sense. What about makemehapi? |
@hueniverse and all the contributors thanks for this amazing experience, I learned a lot from it about how hapijs application should be built. I think it is very important to continue to advance the project, as it is a great way to learn and teach. |
@hueniverse and community, I think moving the project to hapijs is a great idea :-) End GoalIf we focus on the learning objectives described in https://github.com/zoe-1/hapitimes, together we will build boilerplate code for a hapijs web server reviewed and approved by @hueniverse. Assignment StyleAssignments will guide us to build a web server in a step by step process. Each step will be completed with an accepted PR for the assignment, documented with a commit id or branch name. This allow an HTML tutorial to make references to the project in different states of development. New NameI suggest we call the project "tutorial" or "web-tutorial" because that is what we hope to create. @hueniverse If you want to call it something else that is fine too. HTML tutorial@hueniverse is providing his expertise by reviewing our project's code. I think something we can Keep the Hueniversity DistictivesWe all enjoy the learning dynamics of hueniversity. Hueniversity is not just top down (vertical) learning but also sideways (horizontal) learning. I really hope we can keep those characteristics and @hueniverse Hopefully, you find what I wrote above as acceptable. @AdriVanHoudt @hussainanjar @idanwe I am really glad you guys want to contribute. Perhaps, after this project is done we can build an api-tutorial project :-) |
@zoe-1 and whole community, thanks all these thoughts! I think Hapi is a great framework and Hapi community is really awesome. And this project has been great, I am learning a lot. We have to keep it alive. Despite not being highly experienced, I will try to contribute with what I can! |
I like the end goal although I want to hear what the plan from @hueniverse was as to what kind of application he had in mind/goals. I like the idea of splitting up the assignments in branches, this will allow us to easily extract a tutorial with the solution for every assignment. As for the name please don't take anything generic like 'tutorial' or something. It doesn't stand out. Something like makemehapi doesn't feel as daunting to start with imo. I think that the reviewing from @hueniverse is very important. He knows the Hapi coding style and the framework the best. And yes this project has be horizontal no matter what, that's what makes this so great. I would like to hold of on making the solutions public from the start. People finding out themselves and looking at each others PR's is a very important part of the learning process @zoe-1 what are your thoughts on having the wiki also in the repo (or maybe a seperate one)? |
Hi there, |
I will certainly participate as a student. Would it be possible to add something like role-based authorization as a learning point? By that I mean restricting access to certain routes to certain roles/users. For example only admins could POST to /users or something. |
@AdriVanHoudt I appreciate your perspective and feedback :-) In respect to the name, I understand you thoughts. I was thinking the name should represent what the project is about after it is completed. So, having "tutorial" in the name would do this. But, something funny or catchy may work too. Do you have a better suggestion? I do not like school or something-versity in the name because in several months after our project is completed the name no longer has meaning. Glad you like the website idea because I think it would really help people coming from other frameworks or languages to get up to speed with node and hapijs. I hope we will make it :-) I agree with your thoughts about @hueniverse input. But, I hope our efforts will lighten his load. In respect to not providing solutions too early, I agree with you. In respect to the wiki, like you said before wikis are not that great. They are too easy to change and get messed up by others. The suggestion to have a separate repo is a good idea. We should build html guides for each assignment in a separate repo (After the assignment is completed that is). Plus, the separate repo would be a good place to build a tutorial website to complement the completed project. Do you agree? @rutaihwa really glad you are excited about the project. I agree we need to keep it going. @mikejerome Yeah, putting role based access controls in the project is possible. |
Why not? Nodeschool also is a thing. @mikejerome roles are something special I feel. They are highly dependent on the architecture you have and how you define the roles. I think a plugin that looks something like an auth plugin may work. Where you specify the roles on the route config and specify a validateFunction that gets run on every request. You would still need to do the validation yourself though (like auth) |
I like to the idea but I think it's better I use it as student so I can learn much more about hapi |
@AdriVanHoudt I support your opinion about the name. In addition, I prefer University, to stay close as much to the current name. Especially when it will be under the hapijs org, and we may create a tutorial or an app example from this course. I think that creating a tutorial is a great idea too, and it would be nice if we created it as an application, for example an email server. Lately, as a part of the angular-meteor team, we decided to add a tutorial similar to the Hueniversity, and I think it could be a great reference (angular-meteor tutorial). Most of the steps were created by the team and also the community added some (join us!). This is the Github repo that has the matching steps branches. @hueniverse i'm curios to know more about testing schemes (Joi) and db model. Is it possible to add these subject in the next assignment? |
Overall this was very well done by everyone! One comment:
|
Using the
hapi-auth-basic
plugin, add a new/private
endpoint protected by a username and password that returns a simple HTML page with a welcome message. The welcome message should include the logged in username. Do not use any templates (views) at this stage. For username/password validation, create a staticlib/users.json
file (we will replace this in the near future) that contains a few sample users and passwords.The new endpoint will be contained in its own plugin, similar to how we set up
/version
, and will require bringing test coverage back to 100%.Due: 4/27
The text was updated successfully, but these errors were encountered: