>_ IzzyLab

Hands-on task

This task is step 6 of the course “curl and HTTP APIs”

Basic authentication

easy~3 min

The endpoint http://localhost:8080/private is protected by HTTP Basic authentication and answers 401 to anonymous requests. Access it with the username admin and password s3cret and save the response body to /root/secret.txt.

What you'll practise:
  • curl
  • -u
  • Basic auth
  • Authorization
  • 401

Topic breakdown

HTTP Basic authentication passes the username and password in the header Authorization: Basic <base64(user:password)>; without a valid header the server replies 401 Unauthorized. With curl you don't need to encode anything by hand — the -u user:password option builds the header itself. The Basic scheme does not encrypt credentials (it's only base64), so it is only acceptable over HTTPS; for local services and internal APIs it remains a simple way to restrict access.

What's checked

  1. access with username/password

What it looks like