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

[Feature request] Add options to support nested groups for non anonymous fields #24

Closed
lmindwarel opened this issue Jul 8, 2020 · 3 comments

Comments

@lmindwarel
Copy link

Hi !

All in the title, it can be great to have an option to recursively apply groups on childs when the field is an Struct.

@twocs
Copy link

twocs commented Dec 3, 2020

For example, there might be an account with an associated account. The person can see all details of their own account but not all details of the child accounts.

type User struct {
    UserBasicInfo   `groups:"basic"`
    UserPrivateInfo `groups:"secret"`
    Children []User `groups:"basic"`
}
type UserBasicInfo struct {
    ID string
    Email string
}
type UserPrivateInfo struct {
    Secret string
}

Then as a parent I will see:

{
  "ID": "43",
  "Email": "[email protected]",
  "Secret": "I cannot see my children's secrets. I only see my own secrets,",
  "Children": [
    {
      "ID": "44",
      "Email": "[email protected]"
    }
  ]
}

But as a child I will see:

    {
      "ID": "44",
      "Email": "[email protected]",
      "Secret": "I see my own secret"
    }

Currently this will not work because there are already groups on the User struct (the parent will see the child's secrets). Basically would just need a way to override the existing groups of nested groups.

@mweibel
Copy link
Collaborator

mweibel commented Dec 3, 2020

I see the use case but currently don't have enough time to work on this. I'd be happy to review a PR with including tests.

I'd probably make this feature optional or even that you could define it per field.

@mweibel
Copy link
Collaborator

mweibel commented Mar 6, 2024

Closing as not planned currently.

@mweibel mweibel closed this as completed Mar 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants