Restricted endpoints are protected using a DIGEST authentication or an API Key mechanisms.
#### Access model
The endpoints are accessible using three different models:
-
Public publicly accessible
-
User the endpoint can only be accessed by an authenticated user
-
Admin the endpoint can be only be accessed by an authenticated admin user
#### Using the API Key
You can retrieve an API Key from @if (config('app.web_panel')) [your account panel]({{ route('account.login') }}) @else your account panel @endif or using
the dedicated API endpoint.
You can then use your freshly generated key by adding a new `x-api-key` header to your API requests:
```
> GET /api/{endpoint}
> x-api-key: {your-api-key}
> …
```
Or using a cookie:
```
> GET /api/{endpoint}
> Cookie: x-api-key={your-api-key}
> …
```
#### Using DIGEST
To discover the available hashing algorythm you MUST send an unauthenticated request to one of the restricted endpoints.
Only DIGEST-MD5 and DIGEST-SHA-256 are supported through the authentication layer.
A `from` (consisting of the user SIP address, prefixed with `sip:`) header is required to initiate the DIGEST flow.
```
> GET /api/{restricted-endpoint}
> from: sip:foobar@sip.example.org
> …
< HTTP 401
< content-type: application/json
< www-authenticate: Digest realm=test,qop=auth,algorithm=MD5,nonce="{nonce}",opaque="{opaque}"
< www-authenticate: Digest realm=test,qop=auth,algorithm=SHA-256,nonce="{nonce}",opaque="{opaque}"
```
You can find more documentation on the related [IETF RFC-7616](https://tools.ietf.org/html/rfc7616).