(conf_path, temp_folder)
| 104 | |
| 105 | |
| 106 | def from_json(conf_path, temp_folder): |
| 107 | if os.path.exists(conf_path): |
| 108 | file_content = file_utils.read_file(conf_path) |
| 109 | else: |
| 110 | file_content = "{}" |
| 111 | |
| 112 | config = ServerConfig() |
| 113 | |
| 114 | json_object = custom_json.loads(file_content) |
| 115 | |
| 116 | address = "0.0.0.0" |
| 117 | port = 5000 |
| 118 | |
| 119 | ssl = json_object.get("ssl") |
| 120 | if ssl is not None: |
| 121 | key_path = model_helper.read_obligatory(ssl, 'key_path', ' for ssl') |
| 122 | cert_path = model_helper.read_obligatory(ssl, 'cert_path', ' for ssl') |
| 123 | |
| 124 | config.ssl = True |
| 125 | config.ssl_key_path = key_path |
| 126 | config.ssl_cert_path = cert_path |
| 127 | port = 5443 |
| 128 | |
| 129 | if json_object.get("address"): |
| 130 | address = json_object.get("address") |
| 131 | config.address = address |
| 132 | |
| 133 | if json_object.get("port"): |
| 134 | port = json_object.get("port") |
| 135 | config.port = port |
| 136 | |
| 137 | if json_object.get('title'): |
| 138 | config.title = json_object.get('title') |
| 139 | config.enable_script_titles = read_bool_from_config('enable_script_titles', json_object, default=True) |
| 140 | |
| 141 | config.env_vars = _build_env_vars(json_object) |
| 142 | |
| 143 | access_config = json_object.get('access') |
| 144 | if access_config: |
| 145 | allowed_users = access_config.get('allowed_users') |
| 146 | user_groups = model_helper.read_dict(access_config, 'groups') |
| 147 | user_header_name = access_config.get('user_header_name') |
| 148 | else: |
| 149 | allowed_users = None |
| 150 | user_groups = {} |
| 151 | user_header_name = None |
| 152 | |
| 153 | auth_config = json_object.get('auth') |
| 154 | if auth_config: |
| 155 | config.authenticator = create_authenticator( |
| 156 | auth_config, |
| 157 | temp_folder, |
| 158 | process_invoker=ProcessInvoker(config.env_vars)) |
| 159 | |
| 160 | auth_type = config.authenticator.auth_type |
| 161 | if auth_type == 'google_oauth' and allowed_users is None: |
| 162 | raise Exception('access.allowed_users field is mandatory for ' + auth_type) |
| 163 |
nothing calls this directly
no test coverage detected