> For the complete documentation index, see [llms.txt](https://prosbcdocs.telcobridges.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://prosbcdocs.telcobridges.com/telecom-references/protocols/sip-authentication.md).

# SIP Authentication

SIP Authentication is a stateless challenge-based mechanism which ensures user's identity. Authentication challenge can be asked commonly for Invite and Bye methods. This means that anyone receiving an INVITE message can force the sender to prove his or her identity before the message is processed. In fact, SIP authentication is not limited to these two messages type. Any SIP method (the proper name for a SIP message) can be challenged by the recipient.

### WWW (401 Unauthorized) or proxy-auth (407 Proxy Authentication)?

* When authenticating to the server that will deliver a service, a www-authentication header should be used. The 401 (Unauthorized) response message is used by an origin server to challenge the authorization of a user agent.
* When authenticating to a server that will proxy the request to the endpoint, proxy-authentication should be used. The 407 (Proxy Authentication Required) response message is used by a proxy to challenge the authorization of a client.
* In *one* transaction, both www\_authentication and proxy\_authentication can be used
* Normally, messages like INVITE and BYE will receive 407 responses and REGISTER and SUBSCRIBE will receive 401 responses.

### TelcoBridges and SIP Authentication

TelcoBridges can handle SIP Authentication differently according to your network.

* IP to IP calls (FreeSBC/ProSBC)
* TDM to IP calls (Tmedia)

#### Tmedia/FreeSBC/ProSBC

In the case of IP to IP calls commonly for FreeSBC/ProSBC, the challenge messages are forwarded between the SIP device and authentication server.

**Invite callflow:**

![SIP Authentication Ip-IP INVITE](https://docs.telcobridges.com/w/images/f/f0/Sip_authentication_ip-ip_invite.png)

**Bye callflow:**

![SIP Authentication Ip-IP BYE](https://docs.telcobridges.com/w/images/1/1d/Sip_authentication_ip-ip_bye.png)

**Configuration**

By default, TelcoBridges' products will forward authentication challenge messages like INVITE, BYE, REGISTER (see [Sip registration forwarding](https://telcobridges.com/learning/session-border-controller/softphone-and-the-sbc/)), etc.

#### Tmedia/FreeSBC/ProSBC

In the case of TDM to IP calls for Tmedia or Telcobridges product (including FreeSBC/ProSBC) that needs to respond to the authentication challenge message itself. For example, Telcobridges product connecting to SIP trunk, requiring registration and authenticattion to SIP Trunk.

**Invite callflow:**

![SIP Authentication TDM-IP INVITE](https://docs.telcobridges.com/w/images/e/e3/Sip_authentication_tdm-ip_invite.png)

**Bye callflow:**

![SIP Authentication TDM-IP BYE](https://docs.telcobridges.com/w/images/4/46/Sip_authentication_tdm-ip_bye.png)

**Configuration**

The Tmedia needs to configure the 'Authentication Parameters' section for each SIP NAP that requires to respond to authentication challenge messages. See [SIP Registration](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/protocols/sip-registration/README.md) and [SIP Registration to SIP Proxy](https://github.com/telcobridges-main/tmedia-wiki/tree/main/reference/sip-voip/configuring-sip-registration-to-sip-proxy/README.md).

* [v3.0: SIP Authentication](https://github.com/telcobridges-main/tmedia-wiki/tree/main/tmedia/configuration/configuring-sip-authentication/README.md)

### References

* [voip-info.org](https://www.voip-info.org/wiki/view/SIP+Authentication)
* [Sip Authentication](https://www.voip-info.org/sip-authentication)
* [Understanding Sip Authentication](https://andrewjprokop.wordpress.com/2015/01/27/understanding-sip-authentication)


---

# 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 dynamically by asking a question.

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

```
GET https://prosbcdocs.telcobridges.com/telecom-references/protocols/sip-authentication.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
