Skip to content
This repository has been archived by the owner on Mar 31, 2022. It is now read-only.

Role editor copies permissions from child roles and saves them to database #109

Closed
alexbudarov opened this issue Sep 14, 2021 · 1 comment
Assignees
Labels
type: bug Something isn't working
Milestone

Comments

@alexbudarov
Copy link

Jmix: 1.0.2

  • launch attached project (there is one row-level role "restrict-users" defined in code)
    comb.zip

  • create new row-level role "combined", add "restrict-users" as child role

  • save new role

  • reopen combined role for editing

  • you will see that Predicate from the child role has been copied to the "row-level policies" table. With empty join and where clauses.
    rowlvl

  • if you press OK, invalid predicate will be saved to the database.

  • after that you can create user "alex", with (resource roles = Full Access, row-level roles = combined). Relogin, open Users screen and choose some user.

  • you will get an exception:

java.lang.NullPointerException
	at io.jmix.securitydata.impl.role.provider.DatabaseRowLevelRoleProvider.lambda$createPredicateFromScript$1(DatabaseRowLevelRoleProvider.java:109)
	at java.base/java.util.function.Predicate.lambda$and$0(Predicate.java:69)
	at java.base/java.util.function.Predicate.lambda$and$0(Predicate.java:69)
	at io.jmix.core.accesscontext.InMemoryCrudEntityContext.isUpdatePermitted(InMemoryCrudEntityContext.java:75)
	at io.jmix.ui.action.list.EditAction.refreshState(EditAction.java:291)
	at io.jmix.ui.component.impl.AbstractTable.refreshActionsState(AbstractTable.java:1311)
	at io.jmix.ui.component.impl.AbstractTable.tableSourceSelectedItemChanged(AbstractTable.java:1759)
	at io.jmix.ui.component.table.TableDataContainer.datasourceSelectedItemChanged(TableDataContainer.java:322)
	at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
	at io.jmix.ui.component.data.table.ContainerTableItems.containerItemChanged(ContainerTableItems.java:70)
	at io.jmix.core.common.event.EventHub.publish(EventHub.java:170)
	at io.jmix.ui.model.impl.InstanceContainerImpl.fireItemChanged(InstanceContainerImpl.java:167)
	at io.jmix.ui.model.impl.CollectionContainerImpl.setItem(CollectionContainerImpl.java:75)
	at io.jmix.ui.component.data.table.ContainerTableItems.setSelectedItem(ContainerTableItems.java:153)
	at io.jmix.ui.component.impl.AbstractTable.tableSelectionChanged(AbstractTable.java:1196)
	at jdk.internal.reflect.GeneratedMethodAccessor119.invoke(Unknown Source)
...

Because predicates with empty text have been saved to the database.

@alexbudarov alexbudarov added the type: bug Something isn't working label Sep 14, 2021
@knstvk knstvk added this to the 1.1.0 milestone Sep 20, 2021
@gorbunkov
Copy link
Contributor

The issue occurs both in resource and row-level role editors

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants