Search in sources :

Example 1 with Group

use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.

the class FormConfig method fullRepresentation.

/**
 * Return the full representation of the configuration with the configured form fields and meta data.
 */
public FormConfigFullRepresentation fullRepresentation(MetaStorage storage, Subject requestingUser) {
    String ownerName = Optional.ofNullable(owner).map(User::getLabel).orElse(null);
    /* Calculate which groups can see this query.
		 * This is usually not done very often and should be reasonable fast, so don't cache this.
		 */
    List<GroupId> permittedGroups = new ArrayList<>();
    for (Group group : storage.getAllGroups()) {
        for (Permission perm : group.getPermissions()) {
            if (perm.implies(createPermission(Ability.READ.asSet()))) {
                permittedGroups.add(group.getId());
                continue;
            }
        }
    }
    return FormConfigFullRepresentation.builder().id(getId()).formType(formType).label(label).tags(tags).ownerName(ownerName).own(requestingUser.isOwner(this)).createdAt(getCreationTime().atZone(ZoneId.systemDefault())).shared(shared).groups(permittedGroups).values(values).build();
}
Also used : Group(com.bakdata.conquery.models.auth.entities.Group) ArrayList(java.util.ArrayList) ConqueryPermission(com.bakdata.conquery.models.auth.permissions.ConqueryPermission) Permission(org.apache.shiro.authz.Permission) FormConfigPermission(com.bakdata.conquery.models.auth.permissions.FormConfigPermission) ToString(lombok.ToString) GroupId(com.bakdata.conquery.models.identifiable.ids.specific.GroupId)

Example 2 with Group

use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.

the class ManagedExecution method setAdditionalFieldsForStatusWithGroups.

private void setAdditionalFieldsForStatusWithGroups(@NonNull MetaStorage storage, FullExecutionStatus status) {
    /* Calculate which groups can see this query.
		 * This usually is usually not done very often and should be reasonable fast, so don't cache this.
		 */
    List<GroupId> permittedGroups = new ArrayList<>();
    for (Group group : storage.getAllGroups()) {
        for (Permission perm : group.getPermissions()) {
            if (perm.implies(createPermission(Ability.READ.asSet()))) {
                permittedGroups.add(group.getId());
                continue;
            }
        }
    }
    status.setGroups(permittedGroups);
}
Also used : Group(com.bakdata.conquery.models.auth.entities.Group) ArrayList(java.util.ArrayList) ExecutionPermission(com.bakdata.conquery.models.auth.permissions.ExecutionPermission) ConqueryPermission(com.bakdata.conquery.models.auth.permissions.ConqueryPermission) Permission(org.apache.shiro.authz.Permission) GroupId(com.bakdata.conquery.models.identifiable.ids.specific.GroupId)

Example 3 with Group

use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.

the class GroupHandlingTest method execute.

@Override
public void execute(StandaloneSupport conquery) throws Exception {
    MetaStorage storage = conquery.getMetaStorage();
    Group group1 = new Group("company", "company", storage);
    User user1 = new User("user", "user", storage);
    User user1copy = new User("user", "user", storage);
    User user2 = new User("user2", "user2", storage);
    try {
        storage.addGroup(group1);
        storage.addUser(user1);
        group1.addMember(user1);
        group1.addMember(user1copy);
        assertThat(group1.getMembers()).containsExactlyInAnyOrder(user1.getId());
        group1.addMember(user2);
        assertThat(group1.getMembers()).containsExactlyInAnyOrder(user1.getId(), user2.getId());
        group1.removeMember(user2);
        assertThat(group1.getMembers()).containsExactlyInAnyOrder(user1.getId());
    } finally {
        storage.removeUser(user1.getId());
        storage.removeUser(user2.getId());
        storage.removeGroup(group1.getId());
    }
}
Also used : Group(com.bakdata.conquery.models.auth.entities.Group) User(com.bakdata.conquery.models.auth.entities.User) MetaStorage(com.bakdata.conquery.io.storage.MetaStorage)

Example 4 with Group

use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.

the class AdminProcessor method deleteUser.

public synchronized void deleteUser(User user) {
    for (Group group : storage.getAllGroups()) {
        group.removeMember(user);
    }
    storage.removeUser(user.getId());
    log.trace("Removed user {} from the storage.", user.getId());
}
Also used : Group(com.bakdata.conquery.models.auth.entities.Group)

Example 5 with Group

use of com.bakdata.conquery.models.auth.entities.Group in project conquery by bakdata.

the class AdminProcessor method deleteRole.

/**
 * Deletes the mandator, that is identified by the id. Its references are
 * removed from the users, the groups, and from the storage.
 *
 * @param role the role to delete
 */
public void deleteRole(Role role) {
    log.info("Deleting {}", role);
    for (User user : storage.getAllUsers()) {
        user.removeRole(role);
    }
    for (Group group : storage.getAllGroups()) {
        group.removeRole(role);
    }
    storage.removeRole(role.getId());
}
Also used : Group(com.bakdata.conquery.models.auth.entities.Group) User(com.bakdata.conquery.models.auth.entities.User)

Aggregations

Group (com.bakdata.conquery.models.auth.entities.Group)14 User (com.bakdata.conquery.models.auth.entities.User)8 MetaStorage (com.bakdata.conquery.io.storage.MetaStorage)6 Role (com.bakdata.conquery.models.auth.entities.Role)6 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)5 Dataset (com.bakdata.conquery.models.datasets.Dataset)4 ManagedExecutionId (com.bakdata.conquery.models.identifiable.ids.specific.ManagedExecutionId)3 DatasetRegistry (com.bakdata.conquery.models.worker.DatasetRegistry)3 ConqueryPermission (com.bakdata.conquery.models.auth.permissions.ConqueryPermission)2 GroupId (com.bakdata.conquery.models.identifiable.ids.specific.GroupId)2 ArrayList (java.util.ArrayList)2 Permission (org.apache.shiro.authz.Permission)2 Test (org.junit.jupiter.api.Test)2 FormConfigAPI (com.bakdata.conquery.apiv1.forms.FormConfigAPI)1 CQElement (com.bakdata.conquery.apiv1.query.CQElement)1 ConceptQuery (com.bakdata.conquery.apiv1.query.ConceptQuery)1 ExternalUpload (com.bakdata.conquery.apiv1.query.ExternalUpload)1 ExternalUploadResult (com.bakdata.conquery.apiv1.query.ExternalUploadResult)1 Query (com.bakdata.conquery.apiv1.query.Query)1 QueryDescription (com.bakdata.conquery.apiv1.query.QueryDescription)1