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

feat: capability and tags support #35

Closed
chenall opened this issue Nov 22, 2021 · 8 comments
Closed

feat: capability and tags support #35

chenall opened this issue Nov 22, 2021 · 8 comments
Labels
enhancement Enhancement of the code, not introducing new features. help-wanted We need some extra helping hands or expertise in order to resolve this!

Comments

@chenall
Copy link

chenall commented Nov 22, 2021

Feature Request

Describe the Feature Request

Not sure if the self-built controller supports these functions

Additional Context

image
image

@chenall chenall added the enhancement Enhancement of the code, not introducing new features. label Nov 22, 2021
@timothyl13241
Copy link
Contributor

timothyl13241 commented Nov 24, 2021

I agree that it would be nice to be able to change the node tags in the UI. Currently if you have the tags defined under your flow rules as your screenshot shows, you can use an API call to the controller to set the tags.

This is an example of what I've used:
curl -X POST 127.0.0.1:9993/api/network/xxxxxxxxxxxxxxxx/member/xxxxxxxxxx -H "X-ZT1-AUTH:xxxxxxxxxxxxxxxxxxxxxxxx" -d '{ "tags": [[1000,7],[1001,0]]}'

The value after X-ZT1-AUTH is the API token of the ZT controller.

Reference for the controller API is here: https://my.zerotier.com/central-api.html#member-member-post

@dec0dOS dec0dOS added the help-wanted We need some extra helping hands or expertise in order to resolve this! label Nov 24, 2021
@chenall
Copy link
Author

chenall commented Nov 25, 2021

@timothyle97 Yes, and zero-ui Flow rule currently does not support cap and tag, it will be ignored, there may be small bugs.

@dec0dOS

e.g.

tag department
  id 1000 
  enum 100 sales
;

cap super
  id 1000
	accept;
;

image

@timothyl13241
Copy link
Contributor

@chenall If I'm not mistaken the tags are implemented by the ZT controller, not Zero-UI. I believe if the tags are set on the network and the members via the API, any flow rules referencing the tags should work even though the preview shows the tags are empty.

@dec0dOS I've found another project which acts as a command line interface to set the tags on the network and members for ZTNCUI: https://github.com/Fusion/ztncli

@snachx
Copy link

snachx commented Nov 30, 2021

It's indeed a bug in zero-ui's flow rule editor which will ignore tags and caps, I've already fixed it but I haven't do a thoroughly test.

caps = [],
tags = [];
const res = compile(src, rules, caps, tags);
if (!res) {
setFlowData({
rules: [...rules],
capabilities: [...caps],
tags: [...tags],
});

tags and caps should be object instead of array, the rule compiler uses them as objects to store parse result with names as keys.

@dec0dOS
Copy link
Owner

dec0dOS commented Nov 30, 2021

Hello, @snachx, thanks for sharing!

Please reach out to me if it works as expected for you.

@snachx
Copy link

snachx commented Nov 30, 2021

@dec0dOS hello, you can check the detail of the rule compiler

tags[tagName] = {
id: id,
default: dfl,
enums: enums,
flags: flags,
};

caps[capName] = {
id: id,
default: dfl,
rules: capRules,
};

the compile method uses caps and tags different from rules
rules have no names, they will be parsed and pushed to the rules array
both of tags and caps have names, and their names will be keys in the result objects

if we pass arrays as tags and caps, the spread syntax ...tags ...caps can't handle the result returned by the compile method.

I tried to init tags and caps as empty object and change the setFlowData method, it works as expected.

@snachx
Copy link

snachx commented Nov 30, 2021

Also, even if the bug is fixed, the ui interface to set member's group and capabilities still needs to be developed, I've checked MemberSettings.jsx, there's no such support yet. I intend to implement this feature, but don't have time to do it yet.

snachx pushed a commit to snachx/zero-ui that referenced this issue Dec 11, 2021
@dec0dOS
Copy link
Owner

dec0dOS commented Dec 13, 2021

Pull request #41 has been merged to the main branch. This feature will be available with the new release.

Special gratitude goes to @snachx for finding the bug and developing the UI for tags and caps.

@dec0dOS dec0dOS closed this as completed Dec 13, 2021
@github-actions github-actions bot locked and limited conversation to collaborators Jan 13, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement Enhancement of the code, not introducing new features. help-wanted We need some extra helping hands or expertise in order to resolve this!
Projects
None yet
Development

No branches or pull requests

4 participants