@@ -16,7 +16,16 @@ const SearchApplicationSettings: React.FC = () => {
16
16
try {
17
17
const identitiesIndex = ".search-acl-filter-search-sharepoint" //TODO fix hardcoded
18
18
const identitiesPath = searchEndpoint + "/" + identitiesIndex + "/_search"
19
- const response = await fetch ( identitiesPath , { headers : { "Authorization" : "Basic " + btoa ( appUser + ":" + appPassword ) } } ) ;
19
+ const response = await fetch ( identitiesPath , {
20
+ method : "POST" ,
21
+ headers : {
22
+ "Authorization" : "Basic " + btoa ( appUser + ":" + appPassword ) ,
23
+ "Content-Type" : "application/json"
24
+ } ,
25
+ body : JSON . stringify ( {
26
+ "size" : 30 //TODO: fix magic number. This is just how many identities I have in my data
27
+ } )
28
+ } ) ;
20
29
const jsonData = await response . json ( ) ;
21
30
const ids = jsonData . hits . hits . map ( ( hit ) => hit . _id )
22
31
return ids
@@ -55,9 +64,9 @@ const SearchApplicationSettings: React.FC = () => {
55
64
}
56
65
}
57
66
}
58
- const personaRoleDescriptor = async ( ) => {
67
+ const personaRoleDescriptor = async ( persona ) => {
59
68
const identitiesIndex = ".search-acl-filter-search-sharepoint" //TODO fix hardcoded
60
- const identityPath = searchEndpoint + "/" + identitiesIndex + "/_doc/" + searchPersona
69
+ const identityPath = searchEndpoint + "/" + identitiesIndex + "/_doc/" + persona
61
70
const response = await fetch ( identityPath , { headers : { "Authorization" : "Basic " + btoa ( appUser + ":" + appPassword ) } } ) ;
62
71
const jsonData = await response . json ( ) ;
63
72
console . log ( "Permissions lookup response is:" )
@@ -68,39 +77,37 @@ const SearchApplicationSettings: React.FC = () => {
68
77
"cluster" : [ "all" ] ,
69
78
"indices" : [
70
79
{
71
- "names" : [ "search-sharepoint" ] , // TODO: hardcoded
80
+ "names" : [ appName ] ,
72
81
"privileges" : [ "read" ] ,
73
- "query" : {
82
+ "query" : {
74
83
"template" : {
75
84
"params" : {
76
- "permissions " : permissions
85
+ "access_control " : permissions
77
86
} ,
78
- 'source' : `
79
- {
80
- "bool": {
87
+ "source" : `{
88
+ "bool": {
81
89
"filter": {
82
- "bool": {
83
- "should": [
84
- {
85
- "bool": {
86
- "must_not": {
87
- "exists": {
88
- "field": "_allow_access_control"
90
+ "bool": {
91
+ "should": [
92
+ {
93
+ "bool": {
94
+ "must_not": {
95
+ "exists": {
96
+ "field": "_allow_access_control"
97
+ }
98
+ }
99
+ }
100
+ },
101
+ {
102
+ "terms": {
103
+ "_allow_access_control.enum": {{#toJson}}access_control{{/toJson}}
104
+ }
89
105
}
90
- }
91
- }
92
- },
93
- {
94
- "terms": {
95
- "_allow_access_control": {{#toJson}}permissions{{/toJson}}
96
- }
97
- }
98
- ]
99
- }
106
+ ]
107
+ }
100
108
}
101
- }
102
109
}
103
- `
110
+ } `
104
111
}
105
112
}
106
113
}
@@ -114,7 +121,7 @@ const SearchApplicationSettings: React.FC = () => {
114
121
}
115
122
}
116
123
const createPersonaAPIKey = async ( persona ) => {
117
- const roleDescriptor = persona == "admin" ? defaultRoleDescriptor : await personaRoleDescriptor ( )
124
+ const roleDescriptor = persona == "admin" ? defaultRoleDescriptor : await personaRoleDescriptor ( persona )
118
125
const apiKeyPath = searchEndpoint + "/_security/api_key"
119
126
const response = await fetch ( apiKeyPath , {
120
127
method : "POST" ,
0 commit comments