Skip to content

Commit 3049bb7

Browse files
committed
Fixes #658
1 parent eeca0ce commit 3049bb7

File tree

6 files changed

+27
-37
lines changed

6 files changed

+27
-37
lines changed

dashboard-gui/src/javascripts/pages/about_service.jsx

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ import { ReactComponent as EulaIcon } from '../../images/common-file-text-check.
88
import { ReactComponent as RegistrationPolicyIcon } from '../../images/common-file-text-edit.svg'
99
import { ReactComponent as PrivacyStatementIcon } from '../../images/single-neutral-actions-text.svg'
1010

11-
export default function AboutService({ app, type }) {
11+
export default function AboutService({ app, type, currentUser }) {
1212
const [institutions, setInstitutions] = useState(null)
1313

1414
if (!app) {
@@ -22,7 +22,10 @@ export default function AboutService({ app, type }) {
2222
}
2323

2424
useEffect(() => {
25-
fetchInstitutions()
25+
if (!currentUser.guest) {
26+
fetchInstitutions()
27+
}
28+
2629
}, [])
2730

2831
return (
@@ -106,9 +109,10 @@ export default function AboutService({ app, type }) {
106109
)}
107110
</div>
108111
</div>
109-
{app.entityType !== 'single_tenant_template' && <div className="institutions">
110-
<InstitutionTable institutions={institutions} />
111-
</div>}
112+
{(app.entityType !== 'single_tenant_template' && institutions) &&
113+
<div className="institutions">
114+
<InstitutionTable institutions={institutions} />
115+
</div>}
112116
</div>
113117
)
114118
}

dashboard-gui/src/javascripts/pages/service_detail.jsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ export default function ServiceDetail() {
129129
</Route>
130130
)}
131131
<Route>
132-
<AboutService app={app} type={type} />
132+
<AboutService app={app} type={type} currentUser={currentUser}/>
133133
</Route>
134134
</Switch>
135135
</div>

dashboard-server/src/main/java/dashboard/control/ServicesController.java

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
import org.springframework.beans.factory.annotation.Value;
1515
import org.springframework.http.HttpStatus;
1616
import org.springframework.http.ResponseEntity;
17+
import org.springframework.security.access.AuthorizationServiceException;
1718
import org.springframework.security.access.prepost.PreAuthorize;
1819
import org.springframework.util.StringUtils;
1920
import org.springframework.web.bind.annotation.*;
@@ -101,9 +102,12 @@ public RestResponse<List<Service>> byEnntityIds(@RequestBody List<String> entity
101102

102103
@RequestMapping(value = "/idps")
103104
public RestResponse<List<InstitutionIdentityProvider>> getConnectedIdps(
104-
@RequestHeader(HTTP_X_IDP_ENTITY_ID) String idpEntityId,
105105
@RequestParam String spEntityId,
106106
@RequestParam String type) {
107+
CoinUser currentUser = SpringSecurity.getCurrentUser();
108+
if (currentUser.isGuest()) {
109+
throw new AuthorizationServiceException("/idps not allowed for guest)");
110+
}
107111
ServiceProvider serviceProvider = manage.getServiceProvider(spEntityId, EntityType.valueOf(type), false)
108112
.orElseThrow(IllegalArgumentException::new);
109113
List<InstitutionIdentityProvider> idps;
@@ -179,20 +183,12 @@ public ResponseEntity<RestResponse<Service>> get(@RequestHeader(HTTP_X_IDP_ENTIT
179183
Optional<Service> serviceByEntityId = services.getServiceById(idpEntityId, spId, EntityType
180184
.valueOf(entityType), locale);
181185
CoinUser currentUser = SpringSecurity.getCurrentUser();
182-
boolean eraseMails = currentUser.isGuest() || currentUser.isDashboardMember();
183-
184186
return serviceByEntityId
185-
.map(service -> eraseMails ? eraseMailsFromService(service) : service)
187+
.map(service -> service.sanitize(currentUser))
186188
.map(service -> ResponseEntity.ok(createRestResponse(service)))
187189
.orElse(new ResponseEntity<>(HttpStatus.NOT_FOUND));
188190
}
189191

190-
public static Service eraseMailsFromService(Service service) {
191-
service.setSupportMail(null);
192-
service.setContactPersons(Collections.emptyList());
193-
return service;
194-
}
195-
196192
@PreAuthorize("hasAnyRole('DASHBOARD_ADMIN','DASHBOARD_VIEWER','DASHBOARD_SUPER_USER')")
197193
@RequestMapping(value = "/connect", method = RequestMethod.POST)
198194
public ResponseEntity<RestResponse<Action>> connect(@RequestHeader(HTTP_X_IDP_ENTITY_ID) String idpEntityId,

dashboard-server/src/main/java/dashboard/control/UsersController.java

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -283,13 +283,11 @@ public ResponseEntity<RestResponse<Map<String, List<?>>>> idps() {
283283

284284
@RequestMapping(value = "/me/serviceproviders", method = RequestMethod.GET)
285285
public RestResponse<List<Service>> serviceProviders(Locale locale) throws IOException {
286-
List<Service> usersServices = getServiceProvidersForCurrentUser(locale);
287-
288286
CoinUser currentUser = SpringSecurity.getCurrentUser();
289-
boolean eraseMails = currentUser.isGuest() || currentUser.isDashboardMember();
290-
if (eraseMails) {
291-
usersServices = usersServices.stream().map(service -> ServicesController.eraseMailsFromService(service)).collect(toList());
292-
}
287+
List<Service> usersServices = getServiceProvidersForCurrentUser(locale).stream()
288+
.map(service -> service.sanitize(currentUser))
289+
.toList();
290+
293291
return createRestResponse(usersServices);
294292
}
295293

dashboard-server/src/main/java/dashboard/domain/Service.java

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ public class Service implements Comparable<Service>, Serializable {
9292

9393
private ARP arp;
9494

95-
private List<ContactPerson> contactPersons;
9695
private List<String> nameIds;
9796
private String minimalLoaLevel;
9897
private EntityType entityType;
@@ -432,14 +431,6 @@ public void setNoConsentRequired(boolean noConsentRequired) {
432431
this.noConsentRequired = noConsentRequired;
433432
}
434433

435-
public List<ContactPerson> getContactPersons() {
436-
return contactPersons;
437-
}
438-
439-
public void setContactPersons(List<ContactPerson> contactPersons) {
440-
this.contactPersons = contactPersons;
441-
}
442-
443434
public PrivacyInfo getPrivacyInfo() {
444435
return privacyInfo;
445436
}
@@ -627,4 +618,11 @@ public String getOrganisation() {
627618
public void setOrganisation(String organisation) {
628619
this.organisation = organisation;
629620
}
621+
622+
public Service sanitize(CoinUser currentUser) {
623+
if (currentUser.isGuest() || currentUser.isDashboardViewer()) {
624+
this.setSupportMail(null);
625+
}
626+
return this;
627+
}
630628
}

dashboard-server/src/main/java/dashboard/service/impl/ServicesImpl.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -108,12 +108,10 @@ private List<Service> buildApiServices(List<ServiceProvider> services, String la
108108
}
109109

110110
private Service buildApiService(ServiceProvider serviceProvider, String locale) {
111-
112111
Service service = new Service();
113112
plainProperties(serviceProvider, service);
114113
languageSpecificProperties(serviceProvider, locale, service);
115114
categories(serviceProvider, service, locale);
116-
contactPersons(serviceProvider, service);
117115
return service;
118116
}
119117

@@ -236,8 +234,4 @@ private void categories(ServiceProvider sp, Service service, String locale) {
236234
service.setCategories(Collections.singletonList(category));
237235
}
238236

239-
private void contactPersons(ServiceProvider sp, Service service) {
240-
service.setContactPersons(sp.getContactPersons());
241-
}
242-
243237
}

0 commit comments

Comments
 (0)