> For the complete documentation index, see [llms.txt](https://commandbox.ortusbooks.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/security/basic-authentication.md).

# Basic Authentication

CommandBox's web server supports enabling Basic Auth on your sites.

```
server set web.security.basicAuth.enabled=true
server set web.security.realm="My Realm"
server set web.security.basicAuth.users.brad=pass
server set web.security.basicAuth.users.luis=pass2
```

That will create the following data in your `server.json`, which will be picked up the next time you start your server.

```javascript
{
    "web":{
        "security" : {
            "realm" : "My Realm",
            "authPredicate" : "regex( pattern='^/lucee/admin/.*', case-sensitive=false )",
            "basicAuth":{
                "users":{
                    "brad":"pass",
                    "luis":"pass2"
                },
                "enable":"true"
            }
        }
    }
}
```

If there is no `authPredicate` set, basic auth with secure ALL PAGES on the site. Once you set an `authPredicate`, only the pages matching the predicate will require authentication.

The old setting location for Basic Auth (`web.basicAuth`) will STILL WORK until the next major version of CommandBox, but should be considered deprecated. If both the settings exist (Ex: `web.basicAuth.enable` and `web.security.basicAuth.enable`), the new location will be given precedence.

{% hint style="info" %}
For [Multi-Site](/embedded-server/multi-site-support.md), any basic auth settings can be configured on a per-site basis in the `sites` object of the `server.json` or in a `.site.json` file.
{% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://commandbox.ortusbooks.com/embedded-server/configuring-your-server/security/basic-authentication.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
