1
0
Fork 0
mirror of https://github.com/Kozea/Radicale.git synced 2025-06-29 16:55:32 +00:00
Radicale/plugins.md

95 lines
2.9 KiB
Markdown
Raw Normal View History

2016-08-11 19:03:50 +02:00
---
layout: page
title: Plugins
permalink: /plugins/
---
2017-05-24 19:13:47 +02:00
Radicale can be extended by plugins for authentication, rights management and
storage. Plugins are **python** modules.
## Getting started
To get started we walk through the creation of a simple authentication
plugin, that accepts login attempts if the username and password are equal.
The easiest way to develop and install **python** modules is
[Distutils](https://docs.python.org/3/distutils/setupscript.html).
2017-05-27 12:06:41 +02:00
For a minimal setup create the file `setup.py` with the following content
2017-05-24 19:13:47 +02:00
in an empty folder:
```python
#!/usr/bin/env python3
from distutils.core import setup
setup(name="radicale_silly_auth", packages=["radicale_silly_auth"])
2017-05-24 19:13:47 +02:00
```
In the same folder create the sub-folder `radicale_silly_auth`. The folder
2017-05-27 12:06:41 +02:00
must have the same name as specified in `packages` above.
2017-05-24 19:13:47 +02:00
Create the file `__init__.py` in the `radicale_silly_auth` folder with the
2017-05-24 19:13:47 +02:00
following content:
```python
from radicale.auth import BaseAuth
2017-05-24 19:13:47 +02:00
class Auth(BaseAuth):
def is_authenticated(self, user, password):
# Example custom configuration option
foo = ""
if self.configuration.has_option("auth", "foo"):
foo = self.configuration.get("auth", "foo")
self.logger.info("Configuration option %r is %r", "foo", foo)
# Check authentication
2017-06-25 16:02:50 +02:00
self.logger.info("Login attempt by %r with password %r",
2017-05-24 19:13:47 +02:00
user, password)
return user == password
```
Install the python module by running the following command in the same folder
2017-05-27 12:06:41 +02:00
as `setup.py`:
```shell
2017-05-24 19:13:47 +02:00
python3 -m pip install --upgrade .
```
To make use this great creation in Radicale, set the configuration option
`type` in the `auth` section to `radicale_silly_auth`:
```ini
[auth]
type = radicale_silly_auth
foo = bar
```
You can uninstall the module with:
```shell
python3 -m pip uninstall radicale_silly_auth
```
2017-05-24 19:13:47 +02:00
## Authentication plugins
This plugin type is used to check login credentials.
2017-05-27 12:06:41 +02:00
The module must contain a class `Auth` that extends
`radicale.auth.BaseAuth`. Take a look at the file `radicale/auth.py` in
2017-05-24 19:13:47 +02:00
Radicale's source code for more information.
## Rights management plugins
This plugin type is used to check if a user has access to a path.
2017-05-27 12:06:41 +02:00
The module must contain a class `Rights` that extends
2017-05-29 02:04:31 +02:00
`radicale.rights.BaseRights`. Take a look at the file `radicale/rights.py` in
2017-05-24 19:13:47 +02:00
Radicale's source code for more information.
## Web plugins
This plugin type is used to provide the web interface for Radicale.
The module must contain a class `Web` that extends
`radicale.web.BaseWeb`. Take a look at the file `radicale/web.py` in
Radicale's source code for more information.
2017-05-24 19:13:47 +02:00
## Storage plugins
This plugin is used to store collections and items.
2017-06-01 13:14:00 +02:00
The module must contain a class `Collection` that extends
`radicale.storage.BaseCollection`. Take a look at the file `radicale/storage.py`
2017-05-29 02:04:31 +02:00
in Radicale's source code for more information.