3352/fire base remove requirement of app parameters
Showing 2 of 6 files from the diff.
Other files ignored by Codecov
tests/test_api_ttype.py
has changed.
tests/test_lib_tokens_push.py
has changed.
tests/test_api_push_validate.py
has changed.
doc/configuration/sms_gateway_config.rst
has changed.
@@ -480,12 +480,6 @@
Loading
480 | 480 | firebase_configs = get_smsgateway(identifier=fb_identifier, gwtype=GWTYPE) |
|
481 | 481 | if len(firebase_configs) != 1: |
|
482 | 482 | raise ParameterError("Unknown Firebase configuration!") |
|
483 | - | fb_options = firebase_configs[0].option_dict |
|
484 | - | for k in [FIREBASE_CONFIG.PROJECT_NUMBER, FIREBASE_CONFIG.PROJECT_ID, |
|
485 | - | FIREBASE_CONFIG.APP_ID, FIREBASE_CONFIG.API_KEY, |
|
486 | - | FIREBASE_CONFIG.APP_ID_IOS, FIREBASE_CONFIG.API_KEY_IOS]: |
|
487 | - | extra_data[k] = fb_options.get(k) |
|
488 | - | self.add_tokeninfo(FIREBASE_CONFIG.PROJECT_ID, fb_options.get(FIREBASE_CONFIG.PROJECT_ID)) |
|
489 | 483 | # this allows to upgrade our crypto |
|
490 | 484 | extra_data["v"] = 1 |
|
491 | 485 | extra_data["serial"] = self.get_serial() |
@@ -83,12 +83,6 @@
Loading
83 | 83 | REGISTRATION_URL = "registration URL" |
|
84 | 84 | TTL = "time to live" |
|
85 | 85 | JSON_CONFIG = "JSON config file" |
|
86 | - | PROJECT_ID = "projectid" |
|
87 | - | PROJECT_NUMBER = "projectnumber" |
|
88 | - | APP_ID = "appid" |
|
89 | - | API_KEY = "apikey" |
|
90 | - | APP_ID_IOS = "appidios" |
|
91 | - | API_KEY_IOS = "apikeyios" |
|
92 | 86 | HTTPS_PROXY = "httpsproxy" |
|
93 | 87 | ||
94 | 88 |
@@ -158,7 +152,10 @@
Loading
158 | 152 | proxies = {} |
|
159 | 153 | if self.smsgateway.option_dict.get(FIREBASE_CONFIG.HTTPS_PROXY): |
|
160 | 154 | proxies["https"] = self.smsgateway.option_dict.get(FIREBASE_CONFIG.HTTPS_PROXY) |
|
161 | - | url = FIREBASE_URL_SEND.format(self.smsgateway.option_dict.get(FIREBASE_CONFIG.PROJECT_ID)) |
|
155 | + | a = self.smsgateway.option_dict.get(FIREBASE_CONFIG.JSON_CONFIG) |
|
156 | + | with open(a) as f: |
|
157 | + | server_config = json.load(f) |
|
158 | + | url = FIREBASE_URL_SEND.format(server_config["project_id"]) |
|
162 | 159 | resp = authed_session.post(url, data=json.dumps(fcm_message), headers=headers, proxies=proxies) |
|
163 | 160 | ||
164 | 161 | if resp.status_code == 200: |
@@ -182,24 +179,10 @@
Loading
182 | 179 | if server_config: |
|
183 | 180 | if server_config.get("type") != "service_account": |
|
184 | 181 | raise ConfigAdminError(description="The JSON file is not a valid firebase credentials file.") |
|
185 | - | project_id = self.smsgateway.option_dict.get(FIREBASE_CONFIG.PROJECT_ID) |
|
186 | - | if server_config.get("project_id") != project_id: |
|
187 | - | raise ConfigAdminError(description="The project_id you entered does not match the project_id from the JSON file.") |
|
188 | 182 | ||
189 | 183 | else: |
|
190 | 184 | raise ConfigAdminError(description="Please check your configuration. Can not load JSON file.") |
|
191 | 185 | ||
192 | - | # We need at least |
|
193 | - | # FIREBASE_CONFIG.API_KEY_IOS and FIREBASE_CONFIG.APP_ID_IOS |
|
194 | - | # or |
|
195 | - | # FIREBASE_CONFIG.API_KEY and FIREBASE_CONFIG.APP_ID |
|
196 | - | android_configured = bool(self.smsgateway.option_dict.get(FIREBASE_CONFIG.APP_ID)) and \ |
|
197 | - | bool(self.smsgateway.option_dict.get(FIREBASE_CONFIG.API_KEY)) |
|
198 | - | ios_configured = bool(self.smsgateway.option_dict.get(FIREBASE_CONFIG.APP_ID_IOS)) and \ |
|
199 | - | bool(self.smsgateway.option_dict.get(FIREBASE_CONFIG.API_KEY_IOS)) |
|
200 | - | if not android_configured and not ios_configured: |
|
201 | - | raise ConfigAdminError(description="You need to at least configure either app_id and api_key or" |
|
202 | - | " app_id_ios and api_key_ios.") |
|
203 | 186 | ||
204 | 187 | @classmethod |
|
205 | 188 | def parameters(cls): |
@@ -213,35 +196,6 @@
Loading
213 | 196 | params = {"options_allowed": False, |
|
214 | 197 | "headers_allowed": False, |
|
215 | 198 | "parameters": { |
|
216 | - | FIREBASE_CONFIG.PROJECT_ID: { |
|
217 | - | "required": True, |
|
218 | - | "description": _("The project ID, that the client should use. Get it from your Firebase console.") |
|
219 | - | }, |
|
220 | - | FIREBASE_CONFIG.PROJECT_NUMBER: { |
|
221 | - | "required": True, |
|
222 | - | "description": _( |
|
223 | - | "The project number, that the client should use. Get it from your Firebase console.") |
|
224 | - | }, |
|
225 | - | FIREBASE_CONFIG.APP_ID: { |
|
226 | - | "required": False, |
|
227 | - | "description": _( |
|
228 | - | "The App ID, that the Android client should use. Get it from your Firebase console.") |
|
229 | - | }, |
|
230 | - | FIREBASE_CONFIG.API_KEY: { |
|
231 | - | "required": False, |
|
232 | - | "description": _( |
|
233 | - | "The API Key, that the Android client should use. Get it from your Firebase console.") |
|
234 | - | }, |
|
235 | - | FIREBASE_CONFIG.APP_ID_IOS:{ |
|
236 | - | "required": False, |
|
237 | - | "description": _( |
|
238 | - | "The App ID, that the iOS client should use. Get it from your Firebase console.") |
|
239 | - | }, |
|
240 | - | FIREBASE_CONFIG.API_KEY_IOS: { |
|
241 | - | "required": False, |
|
242 | - | "description": _( |
|
243 | - | "The API Key, that the iOS client should use. Get it from your Firebase console.") |
|
244 | - | }, |
|
245 | 199 | FIREBASE_CONFIG.JSON_CONFIG: { |
|
246 | 200 | "required": True, |
|
247 | 201 | "description": _("The filename of the JSON config file, that allows privacyIDEA to talk" |
Files | Coverage |
---|---|
privacyidea | 95.79% |
Project Totals (166 files) | 95.79% |
3648464650
3648464650
3648464650
3648464650
3648464650
3648464650
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file.
The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files.
The size and color of each slice is representing the number of statements and the coverage, respectively.