Skip to content

feat: Device Resolution by Attribute #4857

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

Open
gustavosbarreto opened this issue May 27, 2025 · 0 comments · May be fixed by #4858
Open

feat: Device Resolution by Attribute #4857

gustavosbarreto opened this issue May 27, 2025 · 0 comments · May be fixed by #4858

Comments

@gustavosbarreto
Copy link
Member

gustavosbarreto commented May 27, 2025

Discussed in #4848

Originally posted by No9 May 25, 2025
Currently the device details page is made available through the internal guid in the navigation path.
e.g. https://cloud.shellhub.io/devices/d1ae8d18090f7cb30e1bb827ec6775bd586c0394faacc98a7bc4c2990addce4d
This is a bit problematic for 3rd party integrations where an external systems would like to provide a link to the device remote connection capability in shellhub.
The problem is mainly due to some form of sync integration needing to be developed.
These can be brittle and lead to complexity due to features like compensating transactions being required during the device registration. This problem compounds as more backend management systems are added to the device.

However shellhub has a great feature in the registration process that allows for over riding of the hostname using SHELLHUB_PREFERRED_HOSTNAME.
This allows for a shared id to be established across different management systems greatly simplifying this problem.

To bring this full circle it would be great for the UI to support https://cloud.shellhub.io/devices?hostname=SHELLHUB_PREFERRED_HOSTNAME as a navigation feature directly to the device details page.

Let me know any thoughts on this feature.

Proposal: Device Resolution by Attribute

Problem

Today, the device details page in ShellHub is only accessible using the device’s internal UID:

https://cloud.shellhub.io/devices/d1ae8d18090f7cb30e1bb827ec6775bd586c0394faacc98a7bc4c2990addce4d

This creates problems for 3rd party systems that need to link to ShellHub. These systems usually know the device by its hostname, not UID. This forces developers to write extra logic to keep data in sync, which makes integration harder.

Goal

Allow users and systems to access the device details page in ShellHub using the hostname instead of the UID, with no extra sync logic.

Proposal Overview

This proposal introduces a generic approach to resolving devices by any supported attribute, not just the hostname. The first version will support hostname, but the structure will allow easy addition of other attributes in the future

This change will need updates to both the API (@shellhub-io/backend-owners) and the UI (@shellhub-io/frontend-owners).

API Endpoint: /api/devices/resolve

Usage:

GET /api/devices/resolve?hostname=my-device-name

Parameters:

name description
hostname Hostname of the device

Response:

{
  "uid": "d1ae8d18090f7cb30e1bb827ec6775bd...",
  "hostname": "my-device-name",
  ....
}

NOTE: In the future, other identifiers like mac or serial_number can be supported with similar query parameters.

If the device is not found, the API returns a 404 error.

UI Route: /devices/:identifier?resolver=hostname

Examples:

  • By UID (default): /devices/d1ae8d18090f7cb30e1bb827ec6775bd...
  • By Hostname: /devices/my-device-name?resolver=hostname

Behavior:

If resolver=hostname is in the URL:

  • The UI calls /api/devices/resolve?hostname=:identifier
  • Then it redirects or loads /devices/:uid internally to keep the UI behavior the same

If there is no resolver, the UI assumes :identifier is a UID and loads the page directly according to the current behavior.

Benefits

  • Makes the UI route simple and consistent (/devices/:identifier), regardless of the identifier type
  • The resolver parameter keeps it clear and explicit what kind of identifier is being used
  • External systems can generate device links using only the hostname, without needing to fetch the UID first
  • Reduces integration complexity and removes the need for custom sync logic
  • The API becomes more flexible by allowing queries using different types of identifiers (hostname, mac, etc.)
  • Easy to extend the solution in the future, with minimal changes to the API and UI
@gustavosbarreto gustavosbarreto changed the title feat: Enable deeplinks to device details page using hostname feat: Device Resolution by Hostname Support in ShellHub May 27, 2025
@gustavosbarreto gustavosbarreto changed the title feat: Device Resolution by Hostname Support in ShellHub feat: Device Resolution by Hostname Support May 27, 2025
@gustavosbarreto gustavosbarreto added this to the v0.19.x milestone May 27, 2025
@gustavosbarreto gustavosbarreto changed the title feat: Device Resolution by Hostname Support feat: Device Resolution by Attribute May 27, 2025
heiytor added a commit that referenced this issue May 28, 2025
Implement device resolver functionality that allows fetching devices
using attributes beyond the default UID. The new `resolver` query
parameter accepts different attribute types while automatically scoping
results to the current tenant context for security.

Currently supported resolvers:
- uid (default behavior)
- hostname

Example usage: GET /devices/web-server-01?resolver=hostname
heiytor added a commit that referenced this issue May 29, 2025
Implement device resolver functionality that allows fetching devices
using attributes beyond the default UID. The new `resolver` endpoint
accepts different attribute types while automatically scoping
results to the current tenant context for security.

Currently supported resolvers:
- uid
- hostname
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant