>_ IzzyLab

Hands-on task

This task is step 16 of the course “Networking and HTTP from the terminal”

Request with an Authorization Header

easy~3 min

A local service at http://localhost/secret returns data only when the X-Token: izzy header is present (otherwise 403). Fetch the protected response and save it to /root/secret.txt. In the Site tab the service answers 403: a browser doesn't send that header, but curl can.

What you'll practise:
  • curl
  • http headers
  • -H
  • authentication
  • output redirection

Topic breakdown

HTTP headers are "name: value" pairs that the client sends with a request; they're often used to pass authentication, and the server decides by the value whether to let you in (otherwise it replies 403 Forbidden). In curl, an arbitrary header is added with the -H flag using a string like Name: value (best in single quotes so the shell doesn't mangle it); you can specify several -H flags. The response body is saved to a file with the write flag (-o) or plain > redirection.

What's checked

  1. protected response saved to /root/secret.txt

What it looks like