I tried using os.environ.get("USER") function as I had this data for all the users I want to allow.
var = os.environ.get("USER")
if var in data:
    pass
But a user can change this env variable
export USER=allowed_name
Is there any other way to check the user's validity?