Skip to content

Commit 74aa6fc

Browse files
committed
Hide OIDCC4UI providers' client secrets for non-admin users
1 parent 504cdb9 commit 74aa6fc

1 file changed

Lines changed: 11 additions & 1 deletion

File tree

ext/oidcc4ui/logic/src/main/java/org/apache/syncope/core/logic/OIDCC4UIProviderLogic.java

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import org.apache.syncope.core.persistence.api.dao.OIDCC4UIProviderDAO;
3434
import org.apache.syncope.core.persistence.api.entity.OIDCC4UIProvider;
3535
import org.apache.syncope.core.provisioning.api.data.OIDCC4UIProviderDataBinder;
36+
import org.apache.syncope.core.spring.security.AuthContextUtils;
3637
import org.springframework.security.access.prepost.PreAuthorize;
3738
import org.springframework.transaction.annotation.Transactional;
3839

@@ -89,7 +90,16 @@ public String create(final OIDCC4UIProviderTO opTO) {
8990
@PreAuthorize("isAuthenticated()")
9091
@Transactional(readOnly = true)
9192
public List<OIDCC4UIProviderTO> list() {
92-
return opDAO.findAll().stream().map(binder::getOIDCProviderTO).toList();
93+
boolean isAdmin = AuthContextUtils.getAuthorizations().containsKey(OIDCC4UIEntitlement.OP_READ);
94+
return opDAO.findAll().stream().
95+
map(op -> {
96+
OIDCC4UIProviderTO opTO = binder.getOIDCProviderTO(op);
97+
if (!isAdmin) {
98+
opTO.setClientSecret(null);
99+
}
100+
return opTO;
101+
}).
102+
toList();
93103
}
94104

95105
@PreAuthorize("hasRole('" + OIDCC4UIEntitlement.OP_READ + "')")

0 commit comments

Comments
 (0)