|
| 1 | +# -*- coding: utf-8 -*- |
| 2 | +####### |
| 3 | +# actinia-core - an open source REST API for scalable, distributed, high |
| 4 | +# performance processing of geographical data that uses GRASS GIS for |
| 5 | +# computational tasks. For details, see https://actinia.mundialis.de/ |
| 6 | +# |
| 7 | +# Copyright (c) 2023 mundialis GmbH & Co. KG |
| 8 | +# |
| 9 | +# This program is free software: you can redistribute it and/or modify |
| 10 | +# it under the terms of the GNU General Public License as published by |
| 11 | +# the Free Software Foundation, either version 3 of the License, or |
| 12 | +# (at your option) any later version. |
| 13 | +# |
| 14 | +# This program is distributed in the hope that it will be useful, |
| 15 | +# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 16 | +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 17 | +# GNU General Public License for more details. |
| 18 | +# |
| 19 | +# You should have received a copy of the GNU General Public License |
| 20 | +# along with this program. If not, see <https://www.gnu.org/licenses/>. |
| 21 | +# |
| 22 | +####### |
| 23 | + |
| 24 | +""" |
| 25 | +User management for no authentication |
| 26 | +""" |
| 27 | + |
| 28 | +# from passlib.apps import custom_app_context as pwd_context |
| 29 | +# import jwt |
| 30 | +# from datetime import datetime, timezone, timedelta |
| 31 | +from actinia_core.core.common.config import global_config |
| 32 | +from actinia_core.core.redis_user import redis_user_interface |
| 33 | +from actinia_core.core.common.user import ActiniaUser |
| 34 | + |
| 35 | + |
| 36 | +__author__ = "Anika Weinmann" |
| 37 | +__copyright__ = "Copyright 2023, mundialis GmbH & Co. KG" |
| 38 | +__maintainer__ = "mundialis GmbH & Co. KG" |
| 39 | + |
| 40 | + |
| 41 | +class ActiniaUserNoAuth(ActiniaUser): |
| 42 | + """ |
| 43 | + The Actinia Core user management class for no authentication |
| 44 | + """ |
| 45 | + |
| 46 | + db = redis_user_interface |
| 47 | + |
| 48 | + def __init__(self): |
| 49 | + """Constructor |
| 50 | + Initialize and create a user object for no authentication. |
| 51 | + """ |
| 52 | + self.user_id = global_config.DEFAULT_USER |
| 53 | + self.user_group = global_config.DEFAULT_USER_GROUP |
| 54 | + self.password_hash = None |
| 55 | + self.user_role = "superadmin" |
| 56 | + self.permissions = None |
| 57 | + self.cell_limit = global_config.MAX_CELL_LIMIT |
| 58 | + self.accessible_datasets = { |
| 59 | + "nc_spm_08": ["PERMANENT", "user1", "landsat"], |
| 60 | + "ECAD": ["PERMANENT"], |
| 61 | + "latlong_wgs84": ["PERMANENT"], |
| 62 | + } |
| 63 | + self.accessible_modules = global_config.MODULE_ALLOW_LIST |
| 64 | + self.process_num_limit = global_config.PROCESS_NUM_LIMIT |
| 65 | + self.process_time_limit = global_config.PROCESS_TIME_LIMT |
| 66 | + |
| 67 | + @staticmethod |
| 68 | + def create_user(): |
| 69 | + """Create a new user object for no authentication and initialize it |
| 70 | +
|
| 71 | + Returns: |
| 72 | + actinia_core_api.common.user_noauth.ActiniaUserNoAuth: |
| 73 | + A new user object in case of success, or None in case of failure |
| 74 | + """ |
| 75 | + user = ActiniaUserNoAuth() |
| 76 | + user.hash_password("") |
| 77 | + |
| 78 | + if user.commit() is True: |
| 79 | + return user |
| 80 | + return None |
0 commit comments