Remove legacy AccessToken param

old-commit-hash: 538ca733c7
commatwo_master
Andy Haden 5 years ago
parent edf46c2e19
commit 4abb80c9d6
  1. 2
      common/params.py
  2. 4
      common/tests/test_params.py
  3. 3
      selfdrive/common/params.cc
  4. 2
      selfdrive/manager.py
  5. 11
      selfdrive/registration.py

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

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

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

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

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

Loading…
Cancel
Save