Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] Running in the Windows environment leads to the accidental modification of the security field in in config #1410

Closed
YuanqZh opened this issue May 28, 2024 · 4 comments
Assignees
Labels
bug can be closed If bug fixed or feature is implemented

Comments

@YuanqZh
Copy link

YuanqZh commented May 28, 2024

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]
@imbeacon
Copy link
Member

Hi @YuanqZh ,

Thank you for your interest in ThingsBoard IoT Gateway. Please try to use the version of the gateway from the master branch

@imbeacon imbeacon added the can be closed If bug fixed or feature is implemented label May 28, 2024
@YuanqZh
Copy link
Author

YuanqZh commented May 28, 2024

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

@imbeacon
Copy link
Member

I have changed part of logic today, did you pull the changes and they don't work?

@YuanqZh
Copy link
Author

YuanqZh commented May 28, 2024

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

@YuanqZh YuanqZh closed this as completed May 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug can be closed If bug fixed or feature is implemented
Projects
None yet
Development

No branches or pull requests

3 participants