Skip to content

Commit 31100a5

Browse files
MM1277SebastianRoseneckryzheboka
committed
Closes #2563 - add handling of permissions as access ids
Co-authored-by: SebastianRoseneck <[email protected]> Co-authored-by: ryzheboka <[email protected]>
1 parent 683068a commit 31100a5

File tree

56 files changed

+1496
-215
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

56 files changed

+1496
-215
lines changed

common/taskana-common-data/src/main/resources/sql/sample-data/workbasket-access-list.sql

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
-- sample-data is used for rest tests and for the example application
22

3-
--SERT INTO WORKBASKET_ACCESS_LIST VALUES (ID , WB_ID , ACCESS_ID , ACCESS_NAME , READ , OPEN , APPEND, TRANSFER, DISTRIBUTE, C1 , C2 , C3 , C4 , C5 , C6 , C7 , C8 , C9 , C10 , C11 , C12 , READTASKS, EDITTASKS)
4-
-- KSC authorizations
3+
-- KSC authorizations (ID , WB_ID , ACCESS_ID , ACCESS_NAME , READ , OPEN , APPEND, TRANSFER, DISTRIBUTE, C1, .., C12)
54
-- PPKs
65
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000001', 'WBI:100000000000000000000000000000000004', 'teamlead-1' , 'Titus Toll' , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
76
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000002', 'WBI:100000000000000000000000000000000005', 'teamlead-2' , 'Frauke Faul' , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
@@ -37,7 +36,6 @@ INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:10000000000000000000000000000000
3736
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000017', 'WBI:100000000000000000000000000000000008', 'cn=organisationseinheit ksc 1,cn=organisationseinheit ksc,cn=organisation,ou=test,o=taskana', 'Organisationseinheit KSC 1', true , false, false , false , false , false , false , false , false , false , false , false , false , false , false , false , false ,true , true);
3837
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000018', 'WBI:100000000000000000000000000000000009', 'cn=organisationseinheit ksc 1,cn=organisationseinheit ksc,cn=organisation,ou=test,o=taskana', 'Organisationseinheit KSC 1', true , false, true , false , false , false , false , false , false , false , false , false , false , false , false , false , false ,true , true);
3938

40-
--SERT INTO WORKBASKET_ACCESS_LIST VALUES (ID , WB_ID , ACCESS_ID , ACCESS_NAME , READ , OPEN , APPEND, TRANSFER, DISTRIBUTE, C1 , C2 , C3 , C4 , C5 , C6 , C7 , C8 , C9 , C10 , C11 , C12 ,READTASKS, EDITTASKS)
4139
-- Team GPK access
4240
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000019', 'WBI:100000000000000000000000000000000002', 'cn=organisationseinheit ksc 1,cn=organisationseinheit ksc,cn=organisation,ou=test,o=taskana', 'Organisationseinheit KSC 1', true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
4341
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:100000000000000000000000000000000020', 'WBI:100000000000000000000000000000000003', 'cn=organisationseinheit ksc 2,cn=organisationseinheit ksc,cn=organisation,ou=test,o=taskana', 'Organisationseinheit KSC 2', true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
@@ -64,3 +62,8 @@ INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WBI:00000000000000000000000000000000
6462
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WBI:000000000000000000000000000000000907', 'WBI:000000000000000000000000000000000907', 'user-b-1' , 'Bern, Bernd' , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
6563
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WBI:000000000000000000000000000000000908', 'WBI:000000000000000000000000000000000908', 'user-b-1' , 'Bern, Bernd' , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
6664
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WBI:000000000000000000000000000000000909', 'WBI:000000000000000000000000000000000909', 'user-b-1' , 'Bern, Bernd' , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
65+
66+
-- permissions
67+
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:200000000000000000000000000000000002', 'WBI:100000000000000000000000000000000005', 'taskana:callcenter:ab:ab/a:callcenter' , 'PERM_1' , true , true , true , false , true , false, false, false, false, false, false, false, false, false, false, false, false, true , false);
68+
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:200000000000000000000000000000000003', 'WBI:100000000000000000000000000000000006', 'taskana:callcenter:ab:AB/a:callcenter' , 'PERM_1' , true , false, true , true , false , false, false, false, false, false, false, false, false, false, false, false, false, true , true );
69+
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:200000000000000000000000000000000005', 'WBI:100000000000000000000000000000000012', 'taskana:callcenter:ab:AB/a:callcenter' , 'PERM_1' , true , false, true , false , false , false, false, false, false, false, false, false, false, false, false, false, false, false , false);

common/taskana-common-data/src/main/resources/sql/test-data/workbasket-access-list.sql

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,3 +51,8 @@ INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WBI:00000000000000000000000000000000
5151
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WBI:000000000000000000000000000000000907', 'WBI:000000000000000000000000000000000907', 'user-b-1' , 'Bern, Bernd' , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
5252
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WBI:000000000000000000000000000000000908', 'WBI:000000000000000000000000000000000908', 'user-b-1' , 'Bern, Bernd' , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
5353
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WBI:000000000000000000000000000000000909', 'WBI:000000000000000000000000000000000909', 'user-b-1' , 'Bern, Bernd' , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true , true);
54+
55+
-- permissions
56+
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:200000000000000000000000000000000002', 'WBI:100000000000000000000000000000000005', 'taskana:callcenter:ab:ab/a:callcenter' , 'PERM_1' , true , true , true , false , true , false, false, false, false, false, false, false, false, false, false, false, false, true , false);
57+
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:200000000000000000000000000000000003', 'WBI:100000000000000000000000000000000006', 'taskana:callcenter:ab:ab/a:callcenter' , 'PERM_1' , true , false, true , true , false , false, false, false, false, false, false, false, false, false, false, false, false, true , true );
58+
INSERT INTO WORKBASKET_ACCESS_LIST VALUES ('WAI:200000000000000000000000000000000005', 'WBI:100000000000000000000000000000000012', 'taskana:callcenter:ab:ab/a:callcenter' , 'PERM_1' , true , false, true , false , false , false, false, false, false, false, false, false, false, false, false, false, false, false , false);

common/taskana-common-test/src/main/java/pro/taskana/common/test/security/WithAccessId.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616

1717
String[] groups() default {};
1818

19+
String[] permissions() default {};
20+
1921
@Retention(RetentionPolicy.RUNTIME)
2022
@Target(ElementType.METHOD)
2123
@interface WithAccessIds {

common/taskana-common-test/src/test/java/pro/taskana/common/test/security/JaasExtensionTest.java

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
import java.util.Iterator;
88
import java.util.List;
99
import java.util.function.Supplier;
10-
import java.util.stream.Collectors;
1110
import java.util.stream.Stream;
1211
import org.junit.jupiter.api.AfterAll;
1312
import org.junit.jupiter.api.AfterEach;
@@ -215,11 +214,12 @@ void should_SetMultipleJaasSubjects_When_MultipleAnnotationsExist_On_TestTemplat
215214
assertThat(CURRENT_USER_CONTEXT.getUserid()).isEqualTo(accessId.user());
216215
}
217216

218-
@WithAccessId(user = "testtemplate1", groups = "abc")
217+
@WithAccessId(user = "testtemplate1", groups = "abc", permissions = "perm")
219218
@TestTemplate
220219
void should_InjectCorrectAccessId_When_AnnotationExists_On_TestTemplate(WithAccessId accessId) {
221220
assertThat(accessId.user()).isEqualTo("testtemplate1");
222221
assertThat(accessId.groups()).containsExactly("abc");
222+
assertThat(accessId.permissions()).containsExactly("perm");
223223
}
224224

225225
// endregion
@@ -406,21 +406,21 @@ Stream<DynamicContainer> should_SetAccessIdForDynamicContainerInStream_When_Anno
406406

407407
@TestFactory
408408
Iterable<DynamicTest> should_NotSetAccessIdForDynamicTestInIterable_When_AnnotationIsMissing() {
409-
return Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST).collect(Collectors.toList());
409+
return Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST).toList();
410410
}
411411

412412
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
413413
@TestFactory
414414
Iterable<DynamicTest> should_SetAccessIdForDynamicTestInIterable_When_AnnotationExists() {
415415
return Stream.of(DYNAMIC_TEST_USER_DYNAMIC_TEST, DYNAMIC_TEST_USER_DYNAMIC_TEST)
416-
.collect(Collectors.toList());
416+
.toList();
417417
}
418418

419419
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
420420
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
421421
@TestFactory
422422
Iterable<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterable_When_AnnotationsExist() {
423-
return Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST).collect(Collectors.toList());
423+
return Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST).toList();
424424
}
425425

426426
// WITH DynamicContainer
@@ -431,7 +431,7 @@ Iterable<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterable_When_An
431431
Supplier<DynamicContainer> supplier =
432432
() ->
433433
dynamicContainer("dynamic container", Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST));
434-
return Stream.generate(supplier).limit(2).collect(Collectors.toList());
434+
return Stream.generate(supplier).limit(2).toList();
435435
}
436436

437437
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@@ -443,7 +443,7 @@ Iterable<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterable_When_An
443443
dynamicContainer(
444444
"dynamic container",
445445
Stream.of(DYNAMIC_TEST_USER_DYNAMIC_TEST, DYNAMIC_TEST_USER_DYNAMIC_TEST));
446-
return Stream.generate(supplier).limit(2).collect(Collectors.toList());
446+
return Stream.generate(supplier).limit(2).toList();
447447
}
448448

449449
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@@ -455,7 +455,7 @@ Iterable<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterable_When_An
455455
() ->
456456
dynamicContainer(
457457
"dynamic container", Stream.of(NOT_NULL_DYNAMIC_TEST, NOT_NULL_DYNAMIC_TEST));
458-
return Stream.generate(supplier).limit(2).collect(Collectors.toList());
458+
return Stream.generate(supplier).limit(2).toList();
459459
}
460460

461461
// WITH nested DynamicContainer
@@ -467,7 +467,7 @@ Iterable<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterable_When_An
467467
() -> dynamicContainer("inside container", Stream.of(NULL_DYNAMIC_TEST, NULL_DYNAMIC_TEST));
468468
Supplier<DynamicContainer> outsideSupplier =
469469
() -> dynamicContainer("outside container", Stream.of(supplier.get(), NULL_DYNAMIC_TEST));
470-
return Stream.generate(outsideSupplier).limit(2).collect(Collectors.toList());
470+
return Stream.generate(outsideSupplier).limit(2).toList();
471471
}
472472

473473
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@@ -483,7 +483,7 @@ Iterable<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterable_When_An
483483
() ->
484484
dynamicContainer(
485485
"outside container", Stream.of(supplier.get(), DYNAMIC_TEST_USER_DYNAMIC_TEST));
486-
return Stream.generate(outsideSupplier).limit(2).collect(Collectors.toList());
486+
return Stream.generate(outsideSupplier).limit(2).toList();
487487
}
488488

489489
@WithAccessId(user = INSIDE_DYNAMIC_TEST_USER)
@@ -498,7 +498,7 @@ Iterable<DynamicTest> should_SetMultipleAccessIdForDynamicTestInIterable_When_An
498498
Supplier<DynamicContainer> outsideSupplier =
499499
() ->
500500
dynamicContainer("outside container", Stream.of(supplier.get(), NOT_NULL_DYNAMIC_TEST));
501-
return Stream.generate(outsideSupplier).limit(2).collect(Collectors.toList());
501+
return Stream.generate(outsideSupplier).limit(2).toList();
502502
}
503503

504504
// endregion

history/taskana-simplehistory-rest-spring/src/test/resources/application.properties

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,12 @@ taskana.ldap.groupNameAttribute=cn
3434
taskana.ldap.minSearchForLength=3
3535
taskana.ldap.maxNumberOfReturnedAccessIds=50
3636
taskana.ldap.groupsOfUser=memberUid
37+
taskana.ldap.permissionSearchBase=cn=groups
38+
taskana.ldap.permissionSearchFilterName=objectclass
39+
taskana.ldap.permissionSearchFilterValue=groupofuniquenames
40+
taskana.ldap.permissionNameAttribute=permission
41+
taskana.ldap.permissionsOfUser=uniquemember
42+
taskana.ldap.useDnForGroups=true
3743
# Embedded Spring LDAP server
3844
spring.ldap.embedded.base-dn=OU=Test,O=TASKANA
3945
spring.ldap.embedded.credential.username=uid=admin

lib/taskana-core/src/test/java/acceptance/AbstractAccTest.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ public abstract class AbstractAccTest {
3939
"cn=Organisationseinheit KSC 1,cn=Organisationseinheit KSC,cn=organisation,OU=Test,O=TASKANA";
4040
public static final String GROUP_2_DN =
4141
"cn=Organisationseinheit KSC 2,cn=Organisationseinheit KSC,cn=organisation,OU=Test,O=TASKANA";
42+
public static final String PERM_1 =
43+
"taskana:callcenter:ab:ab/a:callcenter";
4244

4345
protected static TaskanaConfiguration taskanaConfiguration;
4446
protected static TaskanaEngine taskanaEngine;

lib/taskana-core/src/test/java/acceptance/workbasket/query/QueryWorkbasketAccessItemsAccTest.java

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ void testQueryWorkbasketAccessItemValuesForColumnName() throws Exception {
3434

3535
columnValueList =
3636
workbasketService.createWorkbasketAccessItemQuery().listValues(ACCESS_ID, null);
37-
assertThat(columnValueList).hasSize(10);
37+
assertThat(columnValueList).hasSize(11);
3838

3939
columnValueList =
4040
workbasketService.createWorkbasketAccessItemQuery().listValues(WORKBASKET_KEY, null);
@@ -51,9 +51,9 @@ void testQueryAccessItemsForAccessIds() throws Exception {
5151
List<WorkbasketAccessItem> results =
5252
workbasketService
5353
.createWorkbasketAccessItemQuery()
54-
.accessIdIn("user-1-1", GROUP_1_DN)
54+
.accessIdIn("user-1-1", GROUP_1_DN, PERM_1)
5555
.list();
56-
assertThat(results).hasSize(8);
56+
assertThat(results).hasSize(11);
5757
}
5858

5959
@WithAccessId(user = "unknownuser")
@@ -78,12 +78,12 @@ void testQueryAccessItemsForAccessIdsOrderedDescending() throws Exception {
7878
WorkbasketAccessItemQuery query =
7979
workbasketService
8080
.createWorkbasketAccessItemQuery()
81-
.accessIdIn("user-1-1", GROUP_1_DN)
81+
.accessIdIn("user-1-1", GROUP_1_DN, PERM_1)
8282
.orderByAccessId(SortDirection.DESCENDING)
8383
.orderByWorkbasketId(SortDirection.DESCENDING);
8484
List<WorkbasketAccessItem> results = query.list();
8585
long count = query.count();
86-
assertThat(results).hasSize(8).size().isEqualTo(count);
86+
assertThat(results).hasSize(11).size().isEqualTo(count);
8787
assertThat(results.get(0).getId()).isEqualTo("WAI:100000000000000000000000000000000003");
8888
}
8989

@@ -94,12 +94,13 @@ void testQueryAccessItemsForAccessIdsAndWorkbasketKey() throws Exception {
9494
List<WorkbasketAccessItem> results =
9595
workbasketService
9696
.createWorkbasketAccessItemQuery()
97-
.accessIdIn("user-1-1", GROUP_1_DN)
97+
.accessIdIn("user-1-1", GROUP_1_DN, PERM_1)
9898
.workbasketIdIn(
9999
"WBI:100000000000000000000000000000000006",
100-
"WBI:100000000000000000000000000000000002")
100+
"WBI:100000000000000000000000000000000002",
101+
"WBI:100000000000000000000000000000000005")
101102
.list();
102-
assertThat(results).hasSize(3);
103+
assertThat(results).hasSize(5);
103104
}
104105

105106
@WithAccessId(user = "businessadmin")
@@ -135,7 +136,7 @@ void testQueryAccessItemsByWorkbasketKey() throws Exception {
135136
.createWorkbasketAccessItemQuery()
136137
.workbasketIdIn("WBI:100000000000000000000000000000000006")
137138
.list();
138-
assertThat(results).hasSize(3);
139+
assertThat(results).hasSize(4);
139140
}
140141

141142
@WithAccessId(user = "businessadmin")
@@ -149,7 +150,7 @@ void testQueryAccessItemsByWorkbasketKeyOrderedDescending() throws Exception {
149150
.orderByWorkbasketId(SortDirection.DESCENDING)
150151
.orderByAccessId(SortDirection.ASCENDING)
151152
.list();
152-
assertThat(results).hasSize(3);
153+
assertThat(results).hasSize(4);
153154
assertThat(results.get(0).getId()).isEqualTo("WAI:100000000000000000000000000000000009");
154155
}
155156

@@ -160,7 +161,7 @@ void testQueryForIdIn() throws Exception {
160161
String[] expectedIds = {
161162
"WAI:100000000000000000000000000000000001",
162163
"WAI:100000000000000000000000000000000015",
163-
"WAI:100000000000000000000000000000000007"
164+
"WAI:100000000000000000000000000000000006"
164165
};
165166
List<WorkbasketAccessItem> results =
166167
workbasketService.createWorkbasketAccessItemQuery().idIn(expectedIds).list();

0 commit comments

Comments
 (0)