The code from the conference of AFUP that was held 28/08/2018 at JoliCode, Paris.
The slides are available on my slideshare.
Task 1 | Task 2 ➡️ |
---|
Authenticate each request to the application using an identifier and a password.
To facilitate the task we expose a "front controller" to the user. This is a single PHP file through which all requests are processed.
An index.php as a front controller will call SecurityListener at every request. The purpose of SecurityListener as to authenticate a request, in particular :
- extract credentials from the Request object (query parameters "auth_user" and "auth_pw")
- verify credentials
- create Token if credentials are valid
- pass Token into TokenStorage. The last is a service accessible by any other code, e.g. index.php.
Urls to test:
/?auth_user=gordon&auth_pw=freeman
(authenticated)/
(not authenticated)
Urls to test without rewrite rules must start with /index.php
, e.g. /index.php?auth_user=gordon&auth_pw=freeman
.