In this video, Keith Casey demonstrates adding a second middleware (auth) along with how to build out orders and stringing them together.
- View Offline
- [Instructor] Now, let's figure out authentication.…First, since it's middleware,…we can base it on our previous Logging middleware.…We just need to determine how to authenticate.…So lets go to our Middleware folder here…and create a new file called Authentication.…Then we'll go to Logging.…We'll go ahead and copy the whole class…and drop it into Authentication.…Make sure to change the name,…and we'll change the function name too.…And get rid of the Logging.…Logging's not important at this moment.…Now, here's an issue that bit me a number of times…that I want to warn you about.…
Silex, which is a subset of Symfony,…by default does not pass along an authentication header.…So if you're using header-based authentication,…like I suggest in the main portion of this course,…the framework itself will drop it.…You have to come in and make a change to .htaccess…so that it doesn't get dropped.…This is a really subtle issue…that's bitten numerous people online…and caused lots of problems.…So let's just take care of it here.…
This course begins with a simple application specification and builds it one step at a time. Each chapter includes a key concept, with examples from other public APIs, and then shows how to build it yourself with Silex. Learn about URL routing, validating input, and generating response codes and hypermedia payloads. Like any project, the first implementation may be a little messy, but don't worry. The last chapter covers refactoring and what it takes to scale and support the API going forward.
- Understanding the project goals
- Adding authentication with Silex
- Using cross-framework and authentication middleware
- Creating a read-write API in Silex
- Uploading files via an API
- Adding file security
- Creating payloads and response codes in Silex
- Scaling your API