REST APIs and Authentication
REST conventions
| Method | Path | Meaning |
|---|---|---|
| GET | /api/courses | list courses |
| GET | /api/courses/:id | one course |
| POST | /api/courses | create |
| PUT | /api/courses/:id | update |
| DELETE | /api/courses/:id | delete |
JWT authentication
- User logs in with credentials.
- Server verifies and signs a JSON Web Token.
- Client sends it back on every request:
Authorization: Bearer <token>. - Middleware verifies the signature and attaches the user to the request.
Never store plain-text passwords, hash them with bcrypt.