Search in sources :

Example 1 with GroupId

use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId 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 GroupId

use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId 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 GroupId

use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId in project conquery by bakdata.

the class IntrospectionDelegatingRealmTest method tokenIntrospectionGroupedUser.

@Test
public void tokenIntrospectionGroupedUser() {
    STORAGE.addUser(USER_2);
    AuthenticationInfo info = REALM.doGetAuthenticationInfo(USER_2_TOKEN_WRAPPED);
    final ConqueryAuthenticationInfo expected = new ConqueryAuthenticationInfo(USER_2, USER_2_TOKEN_WRAPPED, REALM, true);
    assertThat(info).usingRecursiveComparison().isEqualTo(expected);
    assertThat(STORAGE.getAllUsers()).containsOnly(USER_2);
    // Pre-existing group and a second group that has been added in the process
    assertThat(STORAGE.getAllGroups()).hasSize(2);
    assertThat(STORAGE.getGroup(new GroupId(GROUPNAME_1)).getMembers()).contains(new UserId(USER_2_NAME));
    assertThat(STORAGE.getGroup(new GroupId(GROUPNAME_2)).getMembers()).contains(new UserId(USER_2_NAME));
}
Also used : UserId(com.bakdata.conquery.models.identifiable.ids.specific.UserId) AuthenticationInfo(org.apache.shiro.authc.AuthenticationInfo) GroupId(com.bakdata.conquery.models.identifiable.ids.specific.GroupId) Test(org.junit.jupiter.api.Test)

Example 4 with GroupId

use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId in project conquery by bakdata.

the class SerializationTests method meInformation.

@Test
public void meInformation() throws IOException, JSONException {
    User user = new User("name", "labe", STORAGE);
    MeProcessor.FEMeInformation info = MeProcessor.FEMeInformation.builder().userName(user.getLabel()).hideLogoutButton(false).groups(List.of(new IdLabel<>(new GroupId("test_group"), "test_group_label"))).datasetAbilities(Map.of(new DatasetId("testdataset"), new MeProcessor.FEDatasetAbility(true))).build();
    SerializationTestUtil.forType(MeProcessor.FEMeInformation.class).test(info);
}
Also used : IdLabel(com.bakdata.conquery.apiv1.IdLabel) User(com.bakdata.conquery.models.auth.entities.User) MeProcessor(com.bakdata.conquery.apiv1.MeProcessor) GroupId(com.bakdata.conquery.models.identifiable.ids.specific.GroupId) DatasetId(com.bakdata.conquery.models.identifiable.ids.specific.DatasetId) Test(org.junit.jupiter.api.Test) IdMapSerialisationTest(com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)

Example 5 with GroupId

use of com.bakdata.conquery.models.identifiable.ids.specific.GroupId in project conquery by bakdata.

the class IntrospectionDelegatingRealmTest method tokenIntrospectionGroupedUserRemoveGroupMapping.

@Test
public void tokenIntrospectionGroupedUserRemoveGroupMapping() {
    STORAGE.addUser(USER_3);
    GROUP_1_EXISTING.addMember(USER_3);
    assertThat(STORAGE.getGroup(new GroupId(GROUPNAME_1)).getMembers()).contains(new UserId(USER_3_NAME));
    AuthenticationInfo info = REALM.doGetAuthenticationInfo(USER_3_TOKEN_WRAPPED);
    assertThat(info).usingRecursiveComparison().ignoringFields(ConqueryAuthenticationInfo.Fields.credentials).isEqualTo(new ConqueryAuthenticationInfo(USER_3, USER_3_TOKEN_WRAPPED, REALM, true));
    assertThat(STORAGE.getAllUsers()).containsOnly(USER_3);
    // Pre-existing group
    assertThat(STORAGE.getAllGroups()).hasSize(1);
    assertThat(STORAGE.getGroup(new GroupId(GROUPNAME_1)).getMembers()).doesNotContain(new UserId(USER_3_NAME));
}
Also used : UserId(com.bakdata.conquery.models.identifiable.ids.specific.UserId) AuthenticationInfo(org.apache.shiro.authc.AuthenticationInfo) GroupId(com.bakdata.conquery.models.identifiable.ids.specific.GroupId) Test(org.junit.jupiter.api.Test)

Aggregations

GroupId (com.bakdata.conquery.models.identifiable.ids.specific.GroupId)5 Test (org.junit.jupiter.api.Test)3 Group (com.bakdata.conquery.models.auth.entities.Group)2 ConqueryPermission (com.bakdata.conquery.models.auth.permissions.ConqueryPermission)2 UserId (com.bakdata.conquery.models.identifiable.ids.specific.UserId)2 ArrayList (java.util.ArrayList)2 AuthenticationInfo (org.apache.shiro.authc.AuthenticationInfo)2 Permission (org.apache.shiro.authz.Permission)2 IdLabel (com.bakdata.conquery.apiv1.IdLabel)1 MeProcessor (com.bakdata.conquery.apiv1.MeProcessor)1 User (com.bakdata.conquery.models.auth.entities.User)1 ExecutionPermission (com.bakdata.conquery.models.auth.permissions.ExecutionPermission)1 FormConfigPermission (com.bakdata.conquery.models.auth.permissions.FormConfigPermission)1 IdMapSerialisationTest (com.bakdata.conquery.models.identifiable.IdMapSerialisationTest)1 DatasetId (com.bakdata.conquery.models.identifiable.ids.specific.DatasetId)1 ToString (lombok.ToString)1