Basic authentication lets you restrict access to a Function Compute custom domain name using a username and password. Requests without valid credentials are rejected before reaching your function.
Prerequisites
Before you begin, ensure that you have:
Attached a custom domain name to the function
Before you enable
| Consideration | Details |
|---|---|
| User limit | Up to 20 users per custom domain name |
| Username format | 12–128 characters; must start with a letter; hyphens (-), underscores (_), and periods (.) allowed |
| Password requirements | 12–128 characters; must include uppercase letters, lowercase letters, digits, and at least one of: ! @ # $ % ^ & * ( ) |
| Password hygiene | Don't reuse passwords or use simple combinations; rotate passwords regularly |
| Protocol | Use HTTPS in production. HTTP is for testing only — you are responsible for any credential leaks over HTTP |
| Configuration delay | Allow 1 minute for changes to take effect |
Configure Basic authentication
Log in to the Function Compute console. In the left-side navigation pane, choose Advanced Features > Custom Domains.
In the top menu bar, select a region. On the Domain Names page, find your custom domain name and click Edit in the Actions column.
On the settings page, expand Authentication Settings and set Authentication Method to Basic Authentication.
Under User List, click Add User and enter a Username and Password.
For format requirements, see Before you enable.
Click Save.

Wait 1 minute for the configuration to take effect.
Verify Basic authentication
After configuration takes effect, test that authentication is working correctly.
Generate a Base64-encoded credential. Run the following command — use the
-nflag to prevent a trailing newline from being included in the encoding:# Linux/macOS echo -n "username:password" | base64Example output:
dXNlcm5hbWU6cGFzc3dvcmQ=Send a test request using the encoded credential:
curl -X GET "yourCustomdomain" -H "Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ="Replace
yourCustomdomainwith your actual custom domain name.
Troubleshooting
`authorization required`
The request reached the domain but the Authorization header is missing or its value is incorrect. Check that the header is present and that the encoded credentials match a configured user.
`basic authorization xxx is not a Base64-encoded string`
The value in the Authorization header is not valid Base64. Re-run the encoding command and copy the output exactly.
`Authorization header must start with Basic`
Per RFC 7617, the Authorization header value must start with Basic followed by a space — for example, Authorization: Basic dXNlcm5hbWU6cGFzc3dvcmQ=. Check for missing spaces or extra characters.
FAQ
Does enabling Basic authentication incur extra charges?
No. Function Compute bills based on the number of function invocations, so enabling Basic authentication has no effect on your bill.