[ADD]Initial commit with radicale odoo auth plugin
This commit is contained in:
commit
b54d005919
51
radicale_odoo_auth/__init__.py
Normal file
51
radicale_odoo_auth/__init__.py
Normal file
@ -0,0 +1,51 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
""" Odoo Radicale Authentication Plugin """
|
||||
|
||||
from configparser import Error
|
||||
from odoorpc import ODOO
|
||||
from odoorpc.error import RPCError
|
||||
from radicale.auth import BaseAuth
|
||||
|
||||
|
||||
class Auth(BaseAuth):
|
||||
""" BaseAuth implementation for Odoo Radicale Authentication """
|
||||
|
||||
def is_authenticated(self, user, password):
|
||||
""" Is authenticated main function """
|
||||
host = self.configuration.get('auth', 'host', fallback='127.0.0.1')
|
||||
port = self.configuration.get('auth', 'port', fallback=8069)
|
||||
if not self.configuration.has_option('auth', 'database'):
|
||||
raise RuntimeError('Database is needed for Odoo Authentication')
|
||||
database = self.configuration.get('auth', 'database')
|
||||
if not user or not password:
|
||||
return False
|
||||
try:
|
||||
odoo = ODOO(host, port=port)
|
||||
except RPCError as rpcerr:
|
||||
self.logger.error(rpcerr)
|
||||
raise RuntimeError(rpcerr)
|
||||
try:
|
||||
odoo.login(database, user, password)
|
||||
self.logger.info('Login successfull for {} on database {}'.format(user, database))
|
||||
return True
|
||||
except RPCError as rpcerr:
|
||||
self.logger.error('Login problem for {} on database {}'.format(user, database))
|
||||
self.logger.error(rpcerr)
|
||||
raise RuntimeError(rpcerr)
|
||||
return False
|
25
radicale_odoo_storage/__init__.py
Normal file
25
radicale_odoo_storage/__init__.py
Normal file
@ -0,0 +1,25 @@
|
||||
# -*- coding: utf-8 -*-
|
||||
|
||||
# Copyright 2018 Fabien Bourgeois <fabien@yaltik.com>
|
||||
#
|
||||
# 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 <http://www.gnu.org/licenses/>.
|
||||
|
||||
""" Odoo Radicale Storage Plugin """
|
||||
|
||||
from radicale.storage import BaseCollection
|
||||
|
||||
|
||||
class Collection(BaseCollection):
|
||||
""" BaseCollection implementation for Odoo Radicale Storage """
|
||||
pass
|
Loading…
x
Reference in New Issue
Block a user