Protecting routes

- [Instructor] In our last lesson,…we wrapped up what we needed to do…to handle user authentication within our web service.…In this lesson we're going to handle authorization…and a key component for authorization…is a package called Auth Middleware.…That in conjunction with Protect Middleware…gives your service the ability to provide…authorized access to protected areas…that you want to have in your web service.…So if you wanted to require a username…and password authentication to access…a particular website or if you wanted…to require privileges to be able…to access an external API,…utilizing these two together will give you just that.…

So I'm currently here in main.swiff…and the first thing I need to do is import auth.…So we'll say import Auth.…Next what we want to do is create our auth middleware…object so we'll say let auth = auth middleware.…And when you do this you have to pass it a user model,…so for user we're just going to say user.self.…Once we have that we must then append it…to our droplet and you do that simply by…

Resume Transcript Auto-Scroll

Author

Released

3/14/2017

One of the most compelling aspects of Vapor—an open source, server-side Swift framework—is its ability to work well with a wide array of databases. In this course, discover how to work with Vapor to incorporate SQL and NoSQL databases. Ron Buencamino explains how to install PostgreSQL—an object-relational database system—on your machine, and goes over working with data models, handling user authentication and authorization, and creating and protecting a RESTful interface. Plus, he highlights how to leverage Vapor to create common database-related tasks.

Topics include:

Installing PostgreSQL

Implementing a database provider and a database driver

Working with data models

Implementing functions such as reading, updating, and deleting persisted data