Allow for the unique Device identifier to be scoped to Orgs#2498
Conversation
9452a32 to
dab596e
Compare
|
Yeah this is probably the reasonable approach. for the endpoints, I think supporting the id primarily and only supporting the identifier if using unique platform identifiers makes sense. We should also add an endpoint and channel for: including the org and device identifier. I don't think we expose the internal device_id almost anywhere (if anywhere). We should also do the plumbing to return better errors on connection failures due to duplicate device ids. Right now they are opaque, 401 I believe. This error would live on when a device ends up on multiple products using shared secrets for example. |
I really don't want to surface internal device ids here. How does a user even find an id to then query for? Is it too much to return multiple if they're found, and/or a nice API message to explain multiple were found because of a product setting?
I vote we support The more I think on this feature, the more I'm confused. I read #2495's comments, but isn't it easier to understand why unique device identifiers are the less evil of the two options? |
|
I haven't gotten very far, but before it gets too deep, we should not be considering using an enumerating database ID in any public facing situation. That has been a common security anti-pattern as it greatly increases the likelihood of guess based attacks and interceptions. We are actively moving away from them in many situations. We also should be careful in error responses. While saying "this api request has multiple returns for the identifier" is very helpful, it may provide too much information from a security stance. One could argue that the "internal" topics should not apply, but they are still discoverable to an extent through browser and web tooling quite easily, so I would be hesitant to include enumerating IDs there too. |
|
Had a little async chat with @jjcarstens, he requested
which is reasonable. I will take a look at the two issues I've mentioned, with a possibility of disabling, and hiding from the OpenAPI spec, the APIs used for interacting with a device at the root level. |
a4f8514 to
7644df2
Compare
|
@nshoes @jjcarstens I've addressed the two issues/points I called out in my PR description, and have updated the description to include how it now works. Essentially, no change for self-hosted installs, only NervesCloud (and NervesCloud users) are affected. |
|
Yeah, this looks good to me :) Will let the others chime in. |
nshoes
left a comment
There was a problem hiding this comment.
Sweet, this looks good to me now. Thanks for the putting in the work after the feedback.
… unique device identifiers is enabled
11d95a3 to
d8d2562
Compare
This change allows for Device identifiers to be reused across Orgs.
Device identifiers are unique across the entire platform, and this will remain the default.
To allow for device identifiers to be reused, the env var
PLATFORM_UNIQUE_DEVICE_IDENTIFIERSmust be set to any other value thantrue,TRUE, or1(default istrue).Additionally, you will need to run the following SQL in your DB
DROP INDEX devices_identifier_index;and then
CREATE INDEX devices_identifier_org_id_index ON devices(identifier, org_id);There are two issues which require discussion:
/api/devices/:identifierDeviceEventsStreamChannelwebsocket channelThe API routes
/api/devices/:identifierThe 'short' API routes are only enabled when PLATFORM_UNIQUE_DEVICE_IDENTIFIERS is enabled. I've also hidden them from the Swagger UI when PLATFORM_UNIQUE_DEVICE_IDENTIFIERS is false.
The
DeviceEventsStreamChannelwebsocket channelI've kept support for
device:[device_identifier]ifPLATFORM_UNIQUE_DEVICE_IDENTIFIERSistrue, otherwise users will need to useorg:[org_name]:device:[device_identifier]