| 1 | from ninja.security import HttpBasicAuth |
| 2 | |
| 3 | |
| 4 | class BasicAuth(HttpBasicAuth): |
| 5 | def authenticate(self, request, username, password): |
| 6 | if username == "admin" and password == "secret": |
| 7 | return username |
| 8 | |
| 9 | |
| 10 | @api.get("/basic", auth=BasicAuth()) |
| 11 | def basic(request): |
| 12 | return {"httpuser": request.auth} |