[BUG] Running in the Windows environment leads to the accidental modification of the security field in in config
YuanqZh opened this issue · comments
Describe the bug
Running the code environ.get('username') in the Windows environment will retrieve the default Windows environment username variable ,and it will accidentally replace accessToken in security field with username,which is not what I want
def get_env_variables():
env_variables = {
'host': environ.get('host'),
'port': int(environ.get('port')) if environ.get('port') else None,
'accessToken': environ.get('accessToken'),
'caCert': environ.get('caCert'),
'privateKey': environ.get('privateKey'),
'cert': environ.get('cert'),
'clientId': environ.get('clientId'),
'username': environ.get('username'),
'password': environ.get('password')
}
if environ.get('TB_GW_HOST'):
env_variables['host'] = environ.get('TB_GW_HOST')
if environ.get('TB_GW_PORT'):
env_variables['port'] = int(environ.get('TB_GW_PORT'))
if environ.get('TB_GW_ACCESS_TOKEN'):
env_variables['accessToken'] = environ.get('TB_GW_ACCESS_TOKEN')
if environ.get('TB_GW_CA_CERT'):
env_variables['caCert'] = environ.get('TB_GW_CA_CERT')
if environ.get('TB_GW_PRIVATE_KEY'):
env_variables['privateKey'] = environ.get('TB_GW_PRIVATE_KEY')
if environ.get('TB_GW_CERT'):
env_variables['cert'] = environ.get('TB_GW_CERT')
if environ.get('TB_GW_CLIENT_ID'):
env_variables['clientId'] = environ.get('TB_GW_CLIENT_ID')
if environ.get('TB_GW_USERNAME'):
env_variables['username'] = environ.get('TB_GW_USERNAME')
if environ.get('TB_GW_PASSWORD'):
env_variables['password'] = environ.get('TB_GW_PASSWORD')
if environ.get('TB_GW_RATE_LIMITS'):
env_variables['rateLimits'] = environ.get('TB_GW_RATE_LIMITS')
converted_env_variables = {}
for (key, value) in env_variables.items():
if value is not None:
if key in SECURITY_VAR:
if not converted_env_variables.get('security'):
converted_env_variables['security'] = {}
converted_env_variables['security'][key] = value
else:
converted_env_variables[key] = value
return converted_env_variables
Versions (please complete the following information):
- OS: win11
- 3.5
- Python version[e.g. 3.11]
Hi @YuanqZh ,
Thank you for your interest in ThingsBoard IoT Gateway. Please try to use the version of the gateway from the master branch
Hi @YuanqZh ,
Thank you for your interest in ThingsBoard IoT Gateway. Please try to use the version of the gateway from the master branch
thanks for your reply,the version from the master branch is what i am using now, still the issue occurs
I have changed part of logic today, did you pull the changes and they don't work?
I have changed part of logic today, did you pull the changes and they don't work?
sorry I didn't notice the updates bofere, now it worked,thanks