TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
961 stars 302 forks source link

Claim gateways using a QR code #7270

Open KrishnaIyer opened 2 weeks ago

KrishnaIyer commented 2 weeks ago

Summary

Claim gateways using a QR code.

Current Situation

We can currently claim gateways using an EUI and an owner token.

Why do we need this? Who uses it, and when?

Users with a gateway QR code can claim it. This is very similar to claiming end devices.

Proposed Implementation

Backend:

Frontend:

Contributing

Validation

Code of Conduct

vlasebian commented 2 weeks ago

The ttigw001 is going to be identical to the TR005? Or will it be slightly different?

KrishnaIyer commented 2 weeks ago

Identical in what way?

vlasebian commented 2 weeks ago

Will the implementation be the same?

johanstokking commented 1 week ago

Commented on the PR, that's easier I think.

vlasebian commented 1 week ago

Currently, the request for this endpoint looks like this (the format id is specified as a path argument, or it defaults to a format):

message ParseGatewayQRCodeRequest {
  string format_id = 1 [(validate.rules).string = {
    pattern: "^[a-z0-9](?:[-]?[a-z0-9]){2,}$|^$",
    max_len: 36
  }];
  // Raw QR code contents.
  bytes qr_code = 2 [(validate.rules).bytes = {
    min_len: 10,
    max_len: 1024
  }];
}

From what I understand, the QR code will contain a URL. Will the URL be encoded when sending it to this endpoint in the qr_code field? Because if it's plain text, it will not pass the validation. What I mean is if it's simply sent like this:

{ "qr_code": "https://ttig.pro/c/ec656efffe000128/abcdef123456" }

The endpoint will return the following error:

{"code":3, "message":"proto: (line 1:14): invalid value for bytes type: \"https://ttig.pro/c/ec656efffe000128/abcdef123456\""}

So the URL probably has to be in a base64 encoded form before passing it to the request. Does that make sense? Or would it be better to just change the type of the request field?

@johanstokking

(I left a comment here not in the issue because it might be relevant for fe too)

johanstokking commented 1 week ago

So the URL probably has to be in a base64 encoded form before passing it to the request. Does that make sense? Or would it be better to just change the type of the request field?

Yeah I'm a bit conflicted on this. If we use bytes for the end device QR code, then let's do that here as well. Indeed when using JSON it'd be base64 encoded.