Remove legacy AccessToken param

albatross
Andy Haden 2020-03-23 00:22:41 -07:00
parent a000c76d37
commit 538ca733c7
5 changed files with 9 additions and 13 deletions

View File

@ -52,7 +52,7 @@ class UnknownKeyName(Exception):
keys = {
"AccessToken": [TxType.PERSISTENT],
"AccessToken": [TxType.CLEAR_ON_MANAGER_START],
"AthenadPid": [TxType.PERSISTENT],
"CalibrationParams": [TxType.PERSISTENT],
"CarParams": [TxType.CLEAR_ON_MANAGER_START, TxType.CLEAR_ON_PANDA_DISCONNECT],

View File

@ -42,9 +42,9 @@ class TestParams(unittest.TestCase):
def test_params_two_things(self):
self.params.put("DongleId", "bob")
self.params.put("AccessToken", "knope")
self.params.put("AthenadPid", "123")
assert self.params.get("DongleId") == b"bob"
assert self.params.get("AccessToken") == b"knope"
assert self.params.get("AthenadPid") == b"123"
def test_params_get_block(self):
def _delayed_writer():

View File

@ -292,9 +292,6 @@ int read_db_all(const char* params_path, std::map<std::string, std::string> *par
while ((de = readdir(d))) {
if (!isalnum(de->d_name[0])) continue;
std::string key = std::string(de->d_name);
if (key == "AccessToken") continue;
std::string value = util::read_file(util::string_format("%s/%s", key_path.c_str(), key.c_str()));
(*params)[key] = value;

View File

@ -353,7 +353,7 @@ def manager_init(should_register=True):
if should_register:
reg_res = register()
if reg_res:
dongle_id, dongle_secret = reg_res
dongle_id = reg_res
else:
raise Exception("server registration failed")
else:

View File

@ -36,7 +36,7 @@ def register():
os.chmod(PERSIST+'/comma/', 0o755)
os.chmod(PERSIST+'/comma/id_rsa', 0o744)
dongle_id, access_token = params.get("DongleId", encoding='utf8'), params.get("AccessToken", encoding='utf8')
dongle_id = params.get("DongleId", encoding='utf8')
public_key = open(PERSIST+"/comma/id_rsa.pub").read()
# create registration token
@ -52,15 +52,14 @@ def register():
resp = api_get("v2/pilotauth/", method='POST', timeout=15,
imei=get_imei(0), imei2=get_imei(1), serial=get_serial(), public_key=public_key, register_token=register_token)
dongleauth = json.loads(resp.text)
dongle_id, access_token = dongleauth["dongle_id"], dongleauth["access_token"]
dongle_id = dongleauth["dongle_id"]
params.put("DongleId", dongle_id)
params.put("AccessToken", access_token)
return dongle_id, access_token
return dongle_id
except Exception:
cloudlog.exception("failed to authenticate")
if dongle_id is not None and access_token is not None:
return dongle_id, access_token
if dongle_id is not None:
return dongle_id
else:
return None