From beb0a7adfd0c69fdef2b706378b10f01aceb523b Mon Sep 17 00:00:00 2001 From: ston1th Date: Sun, 21 Aug 2022 14:28:32 +0200 Subject: [PATCH] initial commit --- LICENSE | 24 ++++++++++++++++++++++++ README.md | 13 +++++++++++++ __init__.py | 16 ++++++++++++++++ requirements.txt | 1 + 4 files changed, 54 insertions(+) create mode 100644 LICENSE create mode 100644 README.md create mode 100644 __init__.py create mode 100644 requirements.txt diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..aa39852 --- /dev/null +++ b/LICENSE @@ -0,0 +1,24 @@ +Copyright (C) 2022 Marius Schellenberger +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * The names of the authors and/or contributors may not be used to + endorse or promote products derived from this software without + specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND +ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL ston1th BE LIABLE FOR ANY +DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES +(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; +LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND +ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT +(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS +SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/README.md b/README.md new file mode 100644 index 0000000..7dca54a --- /dev/null +++ b/README.md @@ -0,0 +1,13 @@ +# GoAcc Auth Plugin for Radicale + +GoAcc: https://git.giftfish.de/ston1th/goacc + +Radicale: https://radicale.org/master.html#authentication-plugins + +Config: + +``` +[auth] +type = radicale_goacc_auth +goacc_url = https://accounts.example.com +``` diff --git a/__init__.py b/__init__.py new file mode 100644 index 0000000..d03912d --- /dev/null +++ b/__init__.py @@ -0,0 +1,16 @@ +import requests +from radicale.auth import BaseAuth + +PLUGIN_CONFIG_SCHEMA = {"auth": { + "goacc_url": {"value": "", "type": str}}} + +class Auth(BaseAuth): + def __init__(self, configuration): + super().__init__(configuration.copy(PLUGIN_CONFIG_SCHEMA)) + + def login(self, login, password): + url = self.configuration.get("auth", "goacc_url") + r = requests.get(url+"/auth/basic", auth=(login, password)) + if r.text == "ok\n": + return login + return "" diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..9045e99 --- /dev/null +++ b/requirements.txt @@ -0,0 +1 @@ +requests>=2.28.1