# 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. &#x20;

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.


---

# Agent Instructions: Querying This Documentation

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

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

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

The question should be specific, self-contained, and written in natural language.
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.
