Skip to content
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

Add check if device name is already used #286

Merged
merged 1 commit into from
Dec 28, 2022

Conversation

nathanael-h
Copy link

@nathanael-h nathanael-h commented Dec 22, 2022

Problem

You can overwrite an existing device configuration with a new one by reusing the same name.

Fixes #260

@nathanael-h
Copy link
Author

This prevents adding a device with the name of an existing device.

Here is a screenshot:
Capture d’écran du 2022-12-22 16-36-21 wireguard

I'd like to have a better error message, "This device name is already used." Can someone guide on how to add this?

Logs:

ERRO[0155]device_service.go:30 device name already taken                     grpc.method=AddDevice grpc.service=proto.Devices grpc.start_time="2022-12-22T16:35:38+01:00" span.kind=server system=grpc trace.id=c5f289eb-18c6-4a89-9ab6-f4a4987fabe8

@mergeable
Copy link

mergeable bot commented Dec 22, 2022

Thanks for creating a pull request! A maintainer will review your changes shortly. Please don't be discouraged if it takes a while.

@nathanael-h
Copy link
Author

Mmmh... I think that to improve the error message, we'd need to do this:
// TODO: unwrap grpc error message
https://github.com/freifunkMUC/wg-access-server/blob/master/website/src/components/AddDevice.tsx#L70

In another PR maybe?

@DasSkelett
Copy link
Member

Mmmh... I think that to improve the error message, we'd need to do this: // TODO: unwrap grpc error message master/website/src/components/AddDevice.tsx#L70

In another PR maybe?

This would also need changing:

device, err := d.DeviceManager.AddDevice(user, req.GetName(), req.GetPublicKey())
if err != nil {
ctxlogrus.Extract(ctx).Error(err)
return nil, status.Errorf(codes.Internal, "failed to add device")
}

...but one has to be careful there, as not to leak secrets or other sensitive data through wrapped error messages.

I'm okay with postponing this to another PR, as it is a bit more involved.

@DasSkelett DasSkelett merged commit 1e82815 into freifunkMUC:master Dec 28, 2022
@nathanael-h
Copy link
Author

Hello, do you know when a new release with this PR would be released?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

A configuration with same name can override an existing one
3 participants