- Read Tutorial
- Watch Guide Video
In this section we are going to cover authentication and how we can integrate authentication into our application. One of the first things that you may have noticed if you looked at our product backlog, is that we don't actually have authentication listed and this is another change that we're going to be making in our project plan.
Click on Ruby Gem's integration and double click. if you scroll down you can see where I said I wanted to integrate devise. Devise the tool were going to use to integrate authentication, however, this is a very common pattern where you go through the list of things that you want to implement and you realize that one thing that may have been a subtask actually deserves its own entire sprint.
I'm going to delete it from ruby gems and hit close. Let's create a new item, this one is going to be authentication. I think this is going to be a pretty easy one so we're going to take just two points. Our description can be "implement full authentication" into the portfolio app. As far as tasks go
- we're going to implement the devise gem
- we're going to customize routes
- customize the attributes (That's where we customize the default items like first name, last name and those things that aren't given by a device specifically)
Hit save and we're going to move it to current/backlog.
You may have noticed is all of our other items are gone but don't worry they didn't go anywhere, It's because it's the last time I filmed that we are now in not only a new week and new month but also a new year.
So if I come down and click done, this will show all of the items that we've completed. I think this is actually a good way of going about it, I will keep all three of these columns open from now on. We can have an idea of all the work that we're doing and what we have left.
With this in mind, knowing that we're going to implement authentication, we're going to come to the terminal and I'm going to create a new branch. I can verify that I'm on the master branch and also that I've run git pull, everything is up to date. Those are some standard things that are a good idea to do if you're unsure. Between the last screencast and where we're at right now, I filmed a number of those deep dives that you've been going through so I just want to refresh my own memory.
So with that in mind I know now that I can say
git checkout -b authentication
Now we're going to be on a new branch called called authentication, we'll stay on this one for the entire application.
Let's switch into Chrome where we're going to go and grab this gem. We have a whole section dedicated to ruby gems, for now, I'm just going to give you a very basic introduction.
Our section on gems is going to be much more in depth, I'm going to show how you can research them and we're even going to build our own gems. Go to rubygem.org
Going to devise, this is a very common gem, I use it in nearly every project that I do.
Click on device and you can see the details associated with it.
On the right hand side here you can see the exact code to put into the gemfile. Click on copy to clipboard and then switch into sublime. If you have the project open go to the gemfile, here at the bottom right under friendly_id. we can place devise.
Let's come to the terminal and run
bundle install that is going to go grab the devise library and any of its dependencies.
Before I stop this video and we push up the installation, I want to show a couple of these things because a few of these are actually important. Not only are we installing devise but devise has some very important libraries that it brings in.
The first one here is the bcrypt which is a password type of encryption algorithm. Bcrypt allows us to have secure passwords and that is a very important thing when it comes to creating things like a authentication tool in our app. Our users can be confident that when they type in their username and password we're not storing password as a plain text file that a hacker could see. This is going to encrypt passwords and protect our users.
It also installs the orm_adapter which is another way to connect to the database;
It installed warden which is a very cool tool that is going to give us all kinds of neat functionality for being able to access the application, to be able to store session data and to do a lot of things that we haven't even covered yet.
I won't bore you with them but just I wanted you to at least hear these kind of words because as you go on in your Ruby and Rails development journey, you're going to be seen these type of gems and this one specifically popping up quite a bit.
If I type
git status that shows that only our gemfile has been updated, that's all I want to do in this one guide to keep it nice and short. Type
git add. and `git commit -m "Installed devise gem"
If I type
git push origin origin authentication this is going to push up our authentication branch to github and we're all good to go.
Looking back at the project management dashboard and if I double click that and look at our tasks. This is not quite done. We've implemented the devise gem but in the next guide I'm going to show you how we can actually install it. The next guide is going to be very cool because we are going to have a fully functional log in process.