From b61153b637a83ac1ebc8a7fd33a40663d87a2dc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?F=C3=A9lix=20Pi=C3=A9dallu?= Date: Fri, 13 Dec 2024 22:49:35 +0100 Subject: [PATCH] Add dummy authenticator sockapi --- share/actionsmap.yml | 2 +- src/authenticators/sockapi.py | 44 +++++++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) create mode 100644 src/authenticators/sockapi.py diff --git a/share/actionsmap.yml b/share/actionsmap.yml index ce2d0b92c6..863ca23be4 100755 --- a/share/actionsmap.yml +++ b/share/actionsmap.yml @@ -37,7 +37,7 @@ _global: authentication: api: ldap_admin cli: null - sockapi: null + sockapi: sockapi ############################# # User # diff --git a/src/authenticators/sockapi.py b/src/authenticators/sockapi.py new file mode 100644 index 0000000000..cb830f2c4f --- /dev/null +++ b/src/authenticators/sockapi.py @@ -0,0 +1,44 @@ +#!/usr/bin/env python3 +# +# Copyright (c) 2024 YunoHost Contributors +# +# This file is part of YunoHost (see https://yunohost.org) +# +# This program is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU Affero General Public License for more details. +# +# You should have received a copy of the GNU Affero General Public License +# along with this program. If not, see . +# + +from moulinette.authentication import BaseAuthenticator + + +class Authenticator(BaseAuthenticator): + name = "sockapi" + + def __init__(self, *args, **kwargs): + pass + + def _authenticate_credentials(self, credentials=None): + return {"user": 0} + + def set_session_cookie(self, infos): + pass + + def get_session_cookie(self, raise_if_no_session_exists=True): + return {"id": "pouetpouet"} + + def delete_session_cookie(self): + pass + + @staticmethod + def invalidate_all_sessions_for_user(user): + pass