diff --git a/access_restriction_by_ip/README.rst b/access_restriction_by_ip/README.rst new file mode 100644 index 000000000..fcff8b126 --- /dev/null +++ b/access_restriction_by_ip/README.rst @@ -0,0 +1,17 @@ +Access Restriction By IP V10 +============================ + +This module will restrict users access to his account from the specified IP only. If user access his +account from non-specified IP, login will be restricted and a warning message will be displayed in +login page. + +If no IP is specified for a user, then there will not be restriction by IP. He can access from any IP. + + +Credits +======= +Cybrosys Techno Solutions + +Author +------ +* Niyas Raphy diff --git a/access_restriction_by_ip/__init__.py b/access_restriction_by_ip/__init__.py new file mode 100644 index 000000000..34ede4b19 --- /dev/null +++ b/access_restriction_by_ip/__init__.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +import controllers +import models + diff --git a/access_restriction_by_ip/__manifest__.py b/access_restriction_by_ip/__manifest__.py new file mode 100644 index 000000000..e771bbeb1 --- /dev/null +++ b/access_restriction_by_ip/__manifest__.py @@ -0,0 +1,41 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +{ + 'name': 'Access Restriction By IP', + 'summary': """User Can Access His Account Only From Specified IP Address""", + 'version': '10.0.1.0.0', + 'description': """User Can Access His Account Only From Specified IP Address""", + 'author': 'Cybrosys Techno Solutions', + 'company': 'Cybrosys Techno Solutions', + 'website': 'http://www.cybrosys.com', + 'category': 'Tools', + 'depends': ['base', 'mail'], + 'license': 'AGPL-3', + 'data': [ + 'views/allowed_ips_view.xml', + ], + 'images': ['static/description/banner.jpg'], + 'demo': [], + 'installable': True, + 'auto_install': False, +} diff --git a/access_restriction_by_ip/controllers/__init__.py b/access_restriction_by_ip/controllers/__init__.py new file mode 100644 index 000000000..d9f35f393 --- /dev/null +++ b/access_restriction_by_ip/controllers/__init__.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +import main diff --git a/access_restriction_by_ip/controllers/main.py b/access_restriction_by_ip/controllers/main.py new file mode 100644 index 000000000..9a6f1d71e --- /dev/null +++ b/access_restriction_by_ip/controllers/main.py @@ -0,0 +1,80 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from odoo.addons.web.controllers import main +from odoo.http import request +from odoo.exceptions import Warning +import odoo +import odoo.modules.registry +from odoo.tools.translate import _ +from odoo import http + + +class Home(main.Home): + + @http.route('/web/login', type='http', auth="public") + def web_login(self, redirect=None, **kw): + main.ensure_db() + request.params['login_success'] = False + if request.httprequest.method == 'GET' and redirect and request.session.uid: + return http.redirect_with_hash(redirect) + + if not request.uid: + request.uid = odoo.SUPERUSER_ID + + values = request.params.copy() + try: + values['databases'] = http.db_list() + except odoo.exceptions.AccessDenied: + values['databases'] = None + if request.httprequest.method == 'POST': + old_uid = request.uid + ip_address = request.httprequest.environ['REMOTE_ADDR'] + if request.params['login']: + user_rec = request.env['res.users'].sudo().search([('login', '=', request.params['login'])]) + if user_rec.allowed_ips: + ip_list = [] + for rec in user_rec.allowed_ips: + ip_list.append(rec.ip_address) + if ip_address in ip_list: + uid = request.session.authenticate(request.session.db, request.params['login'], request.params['password']) + if uid is not False: + request.params['login_success'] = True + if not redirect: + redirect = '/web' + return http.redirect_with_hash(redirect) + request.uid = old_uid + values['error'] = _("Wrong login/password") + request.uid = old_uid + values['error'] = _("Not allowed to login from this IP") + else: + uid = request.session.authenticate(request.session.db, request.params['login'], + request.params['password']) + if uid is not False: + request.params['login_success'] = True + if not redirect: + redirect = '/web' + return http.redirect_with_hash(redirect) + request.uid = old_uid + values['error'] = _("Wrong login/password") + + return request.render('web.login', values) diff --git a/access_restriction_by_ip/models/__init__.py b/access_restriction_by_ip/models/__init__.py new file mode 100644 index 000000000..2968d31fe --- /dev/null +++ b/access_restriction_by_ip/models/__init__.py @@ -0,0 +1,24 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +import allowed_ips + diff --git a/access_restriction_by_ip/models/allowed_ips.py b/access_restriction_by_ip/models/allowed_ips.py new file mode 100644 index 000000000..4538ea310 --- /dev/null +++ b/access_restriction_by_ip/models/allowed_ips.py @@ -0,0 +1,36 @@ +# -*- coding: utf-8 -*- +############################################################################## +# +# Cybrosys Technologies Pvt. Ltd. +# Copyright (C) 2017-TODAY Cybrosys Technologies(). +# Author: Niyas Raphy() +# you can modify it under the terms of the GNU LESSER +# GENERAL PUBLIC LICENSE (LGPL v3), Version 3. +# +# It is forbidden to publish, distribute, sublicense, or sell copies +# of the Software or modified copies of the Software. +# +# 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 LESSER GENERAL PUBLIC LICENSE (LGPL v3) for more details. +# +# You should have received a copy of the GNU LESSER GENERAL PUBLIC LICENSE +# GENERAL PUBLIC LICENSE (LGPL v3) along with this program. +# If not, see . +# +############################################################################## +from odoo import models, fields + + +class ResUsersInherit(models.Model): + _inherit = 'res.users' + + allowed_ips = fields.One2many('allowed.ips', 'users_ip', string='IP') + + +class AllowedIPs(models.Model): + _name = 'allowed.ips' + + users_ip = fields.Many2one('res.users', string='IP') + ip_address = fields.Char(string='Allowed IP') diff --git a/access_restriction_by_ip/static/description/access_non_set_ip.png b/access_restriction_by_ip/static/description/access_non_set_ip.png new file mode 100644 index 000000000..1b8f41526 Binary files /dev/null and b/access_restriction_by_ip/static/description/access_non_set_ip.png differ diff --git a/access_restriction_by_ip/static/description/banner.jpg b/access_restriction_by_ip/static/description/banner.jpg new file mode 100644 index 000000000..f5bbd4859 Binary files /dev/null and b/access_restriction_by_ip/static/description/banner.jpg differ diff --git a/access_restriction_by_ip/static/description/cybro_logo.png b/access_restriction_by_ip/static/description/cybro_logo.png new file mode 100644 index 000000000..bb309114c Binary files /dev/null and b/access_restriction_by_ip/static/description/cybro_logo.png differ diff --git a/access_restriction_by_ip/static/description/icon.png b/access_restriction_by_ip/static/description/icon.png new file mode 100644 index 000000000..401fd1ed3 Binary files /dev/null and b/access_restriction_by_ip/static/description/icon.png differ diff --git a/access_restriction_by_ip/static/description/index.html b/access_restriction_by_ip/static/description/index.html new file mode 100644 index 000000000..9f03c006e --- /dev/null +++ b/access_restriction_by_ip/static/description/index.html @@ -0,0 +1,69 @@ +
+
+

Access Restriction By IP

+

User can access his account only from specified IP's

+

Cybrosys Technologies

+
+

This module will restrict the users access to his account from specified IP address only

+
+
+

Features:

+
    +
  •    Administrator can set a IP or a group of IP address for each users
  • +
  •    Users can access their account only from the specified IP's
  • +
  •    Accessing system from a non-specified IP will restrict the user login
  • +
  •    A warning message will be displayed
  • +
  •    If no IP is set to user means there is no any restriction by IP
  • +
  •    IP Address for each users can be set from users form view
  • +
+
+
+
+ +
+
+

Setting IP address for User

+
+

Setting IP address for user from users form view

+

User will be able to access his account only from this IP's

+
+ +
+
+

User accessing his account

+
+

On accessing account from a non specified IP

+
+ +
+

Warning message will be displayed

+
+
+
+ + +
+

Need Any Help?

+ +
diff --git a/access_restriction_by_ip/static/description/index.html~ b/access_restriction_by_ip/static/description/index.html~ new file mode 100644 index 000000000..7f747cbbb --- /dev/null +++ b/access_restriction_by_ip/static/description/index.html~ @@ -0,0 +1,82 @@ +
+
+

Birthday Notification By E-mail

+

This module will wish the employees on their birthday

+ +

Author : Cybrosys Techno Solutions , www.cybrosys.com

+
+

Features:

+
    +
  •    Adds a cron job to invoke email
  • +
  •    Adds an email template
  • +
+
+
+
+ +
+
+
+

Overview

+

+ HR departments need not worry to wish their employees for their Birthday. In this module we have included the feature to send an email Birthday notification to the employee. +

+
+
+
+ +
+
+

Employee Form

+
+

+ ☛ Give Date of Birth for employee.
+ ☛ Give work email.
+

+
+ +
+
+
+
+ +
+
+

Email Template

+
+

+ ☛ The cron job will invoke the email
+ ☛ Email template is very simple
+

+
+ +
+
+
+
+ +
+

Need Any Help?

+ +
diff --git a/access_restriction_by_ip/static/description/user_set_ip.png b/access_restriction_by_ip/static/description/user_set_ip.png new file mode 100644 index 000000000..e6f03f8d1 Binary files /dev/null and b/access_restriction_by_ip/static/description/user_set_ip.png differ diff --git a/access_restriction_by_ip/views/allowed_ips_view.xml b/access_restriction_by_ip/views/allowed_ips_view.xml new file mode 100644 index 000000000..3b7f244d4 --- /dev/null +++ b/access_restriction_by_ip/views/allowed_ips_view.xml @@ -0,0 +1,21 @@ + + + + + res.users + res.users + + + + + + + + + + + + + + +