Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
da24435
Added empty API_KEY to .env files
unkn0wnAPI Jan 22, 2026
7f9fa76
Added an API endpoint controller and placeholders for some api routes
unkn0wnAPI Jan 22, 2026
fd35bd8
Added API endpoints for getting users, user's calendar and sharing ca…
unkn0wnAPI Jan 22, 2026
6f51d2a
Added API endpoints for getting user details, users calendar details
unkn0wnAPI Jan 22, 2026
5a7bf82
Code Linting
unkn0wnAPI Jan 22, 2026
e0ffc32
Added API endpoints for adding/revoking shared calendar
unkn0wnAPI Jan 22, 2026
0b0a66f
Code Linting
unkn0wnAPI Jan 22, 2026
9116764
Changes to share API endpoint path, added information to output
unkn0wnAPI Jan 23, 2026
9d547d5
Changes to API json returns
unkn0wnAPI Jan 23, 2026
2786907
API Docs: Part 1
unkn0wnAPI Jan 23, 2026
c78554b
Fixes to API endpoint params and permissions checks
unkn0wnAPI Jan 25, 2026
f594513
API Docs: Part 2
unkn0wnAPI Jan 25, 2026
d626b69
Updated main README.md file to include information and link to API en…
unkn0wnAPI Jan 25, 2026
154452f
Updated code comments and adjusted user list API endpoint
unkn0wnAPI Jan 25, 2026
f751008
Updated API_KEY variable comment
unkn0wnAPI Jan 25, 2026
e17921f
Add missing request body constraints in docs
unkn0wnAPI Jan 25, 2026
56fca56
Remove needed check/return as per PR comment no. 1
unkn0wnAPI Jan 28, 2026
06a0d16
Add users array, as per PR comment no. 2
unkn0wnAPI Jan 28, 2026
57f04d0
Remove uneeded data false/null check, as per PR comment no. 3
unkn0wnAPI Jan 28, 2026
5ece429
Changed return HTTP code, as per PR comment no. 4
unkn0wnAPI Jan 28, 2026
8871163
Added helper function and moved checks to route requirements, as per PR
unkn0wnAPI Jan 28, 2026
c09e7a3
Added missing array vars and removed uneeded check, as per PR comment…
unkn0wnAPI Jan 28, 2026
49cd4c5
Code Linting
unkn0wnAPI Jan 28, 2026
8423f9e
YAML decleration for custom API authenticator
unkn0wnAPI Jan 28, 2026
cc998aa
Custom API Authenticator logic
unkn0wnAPI Jan 28, 2026
f7ae451
Removed token verification from API endpoint & other cleanups
unkn0wnAPI Jan 28, 2026
70ac8f2
API Improvements: Unified username verification, endpoint allows for …
unkn0wnAPI Jan 29, 2026
019f640
Fixed API Auth on /health endpoint
unkn0wnAPI Jan 29, 2026
d0cf2c7
Added new API endpoint for creating new calendar instances
unkn0wnAPI Jan 29, 2026
4ca0d84
Fix issue regarding AUTH for /api/v1/health endpoint
unkn0wnAPI Jan 31, 2026
8b7f8b3
Polished existing endpoints & Added create/edit endpoint,
unkn0wnAPI Jan 31, 2026
cf57f36
Code Linting
unkn0wnAPI Jan 31, 2026
469046a
Updates to code structure placement order
unkn0wnAPI Feb 1, 2026
bc7c950
Updated README.md and API docs to match changes and additions
unkn0wnAPI Feb 1, 2026
ac84c3c
Bail on empty API_KEY & moved to hash_equals for string comparison
unkn0wnAPI Feb 1, 2026
73e3d6a
Add to API docs, information about API handling when API_KEY is empty
unkn0wnAPI Feb 1, 2026
e179768
Code Linting
unkn0wnAPI Feb 1, 2026
667260b
Moved object count to ORM query, added helper function to check if co…
unkn0wnAPI Feb 1, 2026
ea0818f
ApiController PHPUnit Tests - Part 1
unkn0wnAPI Feb 4, 2026
7d7467a
ApiController Fixes based on ApiControllerTests Failures - Part 1
unkn0wnAPI Feb 4, 2026
b24ef15
ApiController PHPUnit Tests - Part 2
unkn0wnAPI Feb 4, 2026
a90ba7f
Code Linting
unkn0wnAPI Feb 4, 2026
cce1f43
ApiController PHPUnit Tests - Part 3 Assertion Cleanup
unkn0wnAPI Feb 4, 2026
60c9bb1
Docs Update
unkn0wnAPI Feb 4, 2026
2f6145e
Add 2nd Test User for API testing
unkn0wnAPI Feb 4, 2026
584583c
Add check for adding calendar with specific URI
unkn0wnAPI Feb 4, 2026
1570725
Update calendar create docs
unkn0wnAPI Feb 4, 2026
b082d9d
Added 2nd user for API tests
unkn0wnAPI Feb 4, 2026
a72674f
Adjusted API Auth Failure return
unkn0wnAPI Feb 4, 2026
aadea9c
ApiController PHPUnit Tests - Part 4
unkn0wnAPI Feb 4, 2026
389c0fb
Switch from user_id to username in share endpoint
unkn0wnAPI Feb 5, 2026
2619ec3
Final API endpoint version + Docs update
unkn0wnAPI Feb 5, 2026
8a1f3ad
Final API tests suite
unkn0wnAPI Feb 5, 2026
dcf4c6f
Adjust UserControllerTest to match new DataFixture state
unkn0wnAPI Feb 5, 2026
66399d6
Attempted fix to Github CI error - Check if calendar enabled componen…
unkn0wnAPI Feb 5, 2026
24d6746
Commit ommited change to ApiController
unkn0wnAPI Feb 5, 2026
5def1eb
Update access types to match upstream/main & Fix to /shares endpoint
unkn0wnAPI Feb 5, 2026
15165b1
Updated docs
unkn0wnAPI Feb 5, 2026
4d3d3d7
Add missing check from test
unkn0wnAPI Feb 5, 2026
3f2f661
Code Linting
unkn0wnAPI Feb 5, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 8 additions & 1 deletion .env
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,17 @@ WEBDAV_PUBLIC_DIR='/webdav/public'
# such as /webdav/homes for instance, so that users cannot access other users' homes.
WEBDAV_HOMES_DIR=

# API
# When this variable is not empty, the /api endpoint becomes available.
# This endpoint allows admins to perform certain actions that are normally only available
# via the web dashboard.
# To generate a valid API_KEY you can use the php bin/console api:generate command.
API_KEY=

# Logging path
# By default, it will log in the standard Symfony directory: var/log/prod.log (for production)
# You can use /dev/null here if you want to discard logs entirely
LOG_FILE_PATH="%kernel.logs_dir%/%kernel.environment%.log"

# Trust the immediate proxy for X-Forwarded-* headers including HTTPS detection
SYMFONY_TRUSTED_PROXIES=REMOTE_ADDR
SYMFONY_TRUSTED_PROXIES=REMOTE_ADDR
2 changes: 2 additions & 0 deletions .env.test
Original file line number Diff line number Diff line change
Expand Up @@ -8,3 +8,5 @@ PANTHER_ERROR_SCREENSHOT_DIR=./var/error-screenshots
DATABASE_URL="mysql://davis:davis@127.0.0.1:3306/davis_test?serverVersion=10.9.3-MariaDB&charset=utf8mb4"

MAILER_DSN=smtp://localhost:465?encryption=ssl&auth_mode=login&username=&password=

API_KEY=change_me
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,16 @@ The main endpoint for CalDAV, WebDAV or CardDAV is at `/dav`.
>
> For shared hosting, the `symfony/apache-pack` is included and provides a standard `.htaccess` file in the public directory so redirections should work out of the box.

## API Endpoint

For user and calendar management there is an API endpoint. See [the API documentation](docs/api/README.md) for more information.

> [!TIP]
>
> The API endpoint requires an environment variable `API_KEY` set to a secret key that you will use in the `X-Davis-API-Token` header of your requests to authenticate. You can generate it with `bin/console api:generate`

## Webserver Configuration Examples

### Example Caddy 2 configuration

```
Expand Down
8 changes: 8 additions & 0 deletions config/packages/security.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,11 @@ security:
dev:
pattern: ^/(_(profiler|wdt)|css|images|js)/
security: false
api_v1:
pattern: ^/api/v1
stateless: true
custom_authenticators:
- App\Security\ApiKeyAuthenticator
main:
lazy: true
custom_authenticators:
Expand All @@ -16,6 +21,7 @@ security:
logout:
path: app_logout
target: dashboard


access_control:
- { path: ^/$, roles: PUBLIC_ACCESS }
Expand All @@ -24,3 +30,5 @@ security:
- { path: ^/users, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
- { path: ^/calendars, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
- { path: ^/adressbooks, roles: ROLE_ADMIN, allow_if: "'%env(default:default_admin_auth_bypass:ADMIN_AUTH_BYPASS)%' === 'true'" }
- { path: ^/api/v1/health$, roles: PUBLIC_ACCESS }
- { path: ^/api, roles: IS_AUTHENTICATED }
4 changes: 4 additions & 0 deletions config/services.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,10 @@ services:
arguments:
$birthdayReminderOffset: "%birthday_reminder_offset%"

App\Security\ApiKeyAuthenticator:
arguments:
$apiKey: "%env(API_KEY)%"

when@dev:
services:
Symfony\Component\HttpKernel\Profiler\Profiler: '@profiler'
Expand Down
34 changes: 34 additions & 0 deletions docs/api/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Davis API

## API Version 1

### Open Endpoints

Open endpoints require no Authentication.

* [Health](v1/health.md) : `GET /api/v1/health`

### Endpoints that require Authentication

Closed endpoints require a valid `X-Davis-API-Token` to be included in the header of the request. Token needs to be configured in .env file (as a environment variable `API_KEY`) and can be generated using `php bin/console api:generate` command.

When `API_KEY` is not set, the API endpoints are disabled and will return a 500 error if accessed.

#### User related

Each endpoint displays information related to the User:

* [Get Users](v1/users/all.md) : `GET /api/v1/users`
* [Get User Details](v1/users/details.md) : `GET /api/v1/users/:username`

#### Calendars related

Endpoints for viewing and modifying user calendars.

* [Show All User Calendars](v1/calendars/all.md) : `GET /api/v1/calendars/:username`
* [Show User Calendar Details](v1/calendars/details.md) : `GET /api/v1/calendars/:username/:calendar_id`
* [Create User Calendar](v1/calendars/create.md) : `POST /api/v1/calendars/:username/create`
* [Edit User Calendar](v1/calendars/edit.md) : `POST /api/v1/calendars/:username/:calendar_id/edit`
* [Show User Calendar Shares](v1/calendars/shares.md) : `GET /api/v1/calendars/:username/shares/:calendar_id`
* [Share User Calendar](v1/calendars/share_add.md) : `POST /api/v1/calendars/:username/share/:calendar_id/add`
* [Remove Share User Calendar](v1/calendars/share_remove.md) : `POST /api/v1/calendars/:username/share/:calendar_id/remove`
110 changes: 110 additions & 0 deletions docs/api/v1/calendars/all.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
# User Calendars

Gets a list of all available calendars for a specific user.

**URL** : `/api/v1/calendars/:username`

**Method** : `GET`

**Auth required** : YES

**Params constraints**

```
:username -> "[username in plain text]",
```

**URL example**

```json
/api/v1/calendars/jdoe
```

## Success Response

**Code** : `200 OK`

**Notes**: The `events`, `notes`, and `tasks` fields return a count (number) if the component is enabled for the calendar, or `null` if the component is disabled.

**Content examples**

```json
{
"status": "success",
"data": {
"user_calendars": [
{
"id": 1,
"uri": "default",
"displayname": "Default Calendar",
"events": 0,
"notes": null,
"tasks": null
}
],
"shared_calendars": [
{
"id": 10,
"uri": "c2152eb0-ada1-451f-bf33-b4a9571ec92e",
"displayname": "Default Calendar",
"events": 0,
"notes": null,
"tasks": null
}
],
"subscriptions": []
},
"timestamp": "2026-01-23T15:01:33+01:00"
}
```

Shown when user does not have calendars:
```json
{
"status": "success",
"data": {
"user_calendars": [],
"shared_calendars": [],
"subscriptions": []
},
"timestamp": "2026-01-23T15:01:33+01:00"
}
```

## Error Response

**Condition** : If 'X-Davis-API-Token' is not present or mismatched in headers.

**Code** : `401 UNAUTHORIZED`

**Content** :

```json
{
"message": "No API token provided",
"timestamp": "2026-01-23T15:01:33+01:00"
}
```

or

```json
{
"message": "Invalid API token",
"timestamp": "2026-01-23T15:01:33+01:00"
}
```

**Condition** : If user is not found.

**Code** : `404 NOT FOUND`

**Content** :

```json
{
"status": "error",
"message": "User Not Found",
"timestamp": "2026-01-23T15:01:33+01:00"
}
```
Loading