perf: 更新 chrome 支持匿名账号

pull/11408/head^2
Eric 2023-07-06 11:47:25 +08:00 committed by Bryan
parent a2a5d5e08b
commit 6a720cde0a
4 changed files with 20 additions and 8 deletions

View File

@ -0,0 +1,3 @@
# 2023-07-06 Version 0.5
## 功能更新
- 增加匿名用户的支持如果账号是匿名用户username 和 secret 则为空

View File

@ -5,3 +5,6 @@
- Chrome 和 ChromeDriver 版本要匹配
- Driver [下载地址](https://chromedriver.chromium.org/downloads)
## ChangeLog
一些重要的更新记录参考 [ChangeLog](./ChangeLog.md)

View File

@ -135,6 +135,14 @@ class WebAPP(object):
self.account = account
self.platform = platform
self._steps = list()
# 确保 account_username 和 account_secret 不为 None
self._account_username = account.username if account.username else ''
self._account_secret = account.secret if account.secret else ''
# 如果是匿名账号account_username 和 account_secret 为空
if account.username == "@ANON":
self._account_username = ''
self._account_secret = ''
extra_data = self.asset.spec_info
autofill_type = extra_data.autofill
@ -153,23 +161,22 @@ class WebAPP(object):
for item in steps:
val = item.value
if val:
val = val.replace("{USERNAME}", self.account.username)
val = val.replace("{SECRET}", self.account.secret)
val = val.replace("{USERNAME}", self._account_username)
val = val.replace("{SECRET}", self._account_secret)
item.value = val
self._steps.append(item)
def _default_custom_steps(self, spec_info) -> list:
account = self.account
default_steps = [
return [
Step({
"step": 1,
"value": account.username,
"value": self._account_username,
"target": spec_info.username_selector,
"command": "type"
}),
Step({
"step": 2,
"value": account.secret,
"value": self._account_secret,
"target": spec_info.password_selector,
"command": "type"
}),
@ -180,7 +187,6 @@ class WebAPP(object):
"command": "click"
})
]
return default_steps
def execute(self, driver: webdriver.Chrome) -> bool:
if not self.asset.address:

View File

@ -1,6 +1,6 @@
name: chrome
display_name: "{{ 'Chrome Browser' | trans }}"
version: 0.4
version: 0.5
comment: "{{ 'Chrome Browser Open URL Page Address' | trans }}"
author: JumpServer Team
exec_type: python