Section 7: Lab: Sign-Up and Basic Auth
- A sign-up endpoint with password_hash
- Check passwords with password_verify
- Basic Auth in the Authorization header, and why HTTPS is required
- The limits of Basic Auth compared with tokens
Section 8: Lab: Authentication with JWT
- The structure of a JWT: header, payload and signature
- Create and verify tokens with firebase/php-jwt
- Set expiry times and handle expired tokens
- Middleware that checks the bearer token before an endpoint
Section 9: CORS and API Security
- CORS and preflight requests when calling from JavaScript
- Simple request rate limiting
- Check data ownership before updates and deletes
- A checklist based on the OWASP API Security Top 10
Section 10: Lab: A Single-Page Web Front End for the API
- A page built with HTML, Bootstrap 5 and the Fetch API
- Sign up, log in and store the token with care
- Create articles and list them by category
- Show API errors in a way users understand
Section 11: Lab: Calling External APIs with Guzzle
- Install Guzzle with Composer
- Send GET and POST requests with query strings and JSON
- Asynchronous requests and concurrent requests with a pool
- Handle timeouts and errors from external services
Section 12: Workshop: The Article API with Documentation, Deployed
- Combine every endpoint with JWT authentication
- Document the API with OpenAPI
- Deploy to a web server with public as the document root
- Use an AI assistant to review code with care, and next steps towards a framework