Skip to content

Commit

Permalink
Merge pull request #1598 from siemens/fix/nowriteaccess
Browse files Browse the repository at this point in the history
fix(UI): Disable write access from UI

Reviewed by: abdul.kapti@siemens-healthineers.com
Tested by: abdul.kapti@siemens-healthineers.com
  • Loading branch information
ag4ums authored Sep 15, 2022
2 parents 2a4a9a2 + b8190e2 commit 1abff27
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -651,6 +651,7 @@ public class PortalConstants {
// Rest API constants
public static final UserGroup API_WRITE_ACCESS_USERGROUP;
public static final Boolean API_TOKEN_ENABLE_GENERATOR;
public static final Boolean REST_API_WRITE_ACCESS_TOKEN_IN_PREFERENCES;
public static final String API_TOKEN_MAX_VALIDITY_READ_IN_DAYS;
public static final String API_TOKEN_MAX_VALIDITY_WRITE_IN_DAYS;
public static final String API_TOKEN_HASH_SALT;
Expand Down Expand Up @@ -693,6 +694,7 @@ public class PortalConstants {
CUSTOM_WELCOME_PAGE_GUIDELINE = Boolean.parseBoolean(props.getProperty("custom.welcome.page.guideline", "false"));
// SW360 REST API Constants
API_TOKEN_ENABLE_GENERATOR = Boolean.parseBoolean(props.getProperty("rest.apitoken.generator.enable", "false"));
REST_API_WRITE_ACCESS_TOKEN_IN_PREFERENCES = Boolean.parseBoolean(props.getProperty("rest.api.write.access.token.in.preferences", "false"));
API_TOKEN_MAX_VALIDITY_READ_IN_DAYS = props.getProperty("rest.apitoken.read.validity.days", "90");
API_TOKEN_MAX_VALIDITY_WRITE_IN_DAYS = props.getProperty("rest.apitoken.write.validity.days", "30");
API_TOKEN_HASH_SALT = props.getProperty("rest.apitoken.hash.salt", "$2a$04$Software360RestApiSalt");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@
<jsp:useBean id="accessTokenList" type="java.util.List<org.eclipse.sw360.datahandler.thrift.users.RestApiToken>" scope="request"/>

<core_rt:set var="enableTokenGenerator" value='<%=PortalConstants.API_TOKEN_ENABLE_GENERATOR%>'/>

<core_rt:set var="disableWriteAccess" value='<%=PortalConstants.REST_API_WRITE_ACCESS_TOKEN_IN_PREFERENCES%>'/>
<div class="container">
<div class="row">
<div class="col">
Expand Down Expand Up @@ -157,9 +157,11 @@
id="authorities_read" class="form-check-input" />
<label class="form-check-label" for="authorities_read"><liferay-ui:message key="read.access" /></label>
<br>
<core_rt:if test="${disableWriteAccess}">
<input type="checkbox" name="<portlet:namespace/><%=RestApiToken._Fields.AUTHORITIES%>WRITE"
id="authorities_write" class="form-check-input" />
<label class="form-check-label" for="authorities_write"><liferay-ui:message key="write.access" /></label>
</core_rt:if>
</div>
</td>
</tr>
Expand Down
1 change: 1 addition & 0 deletions frontend/sw360-portlet/src/main/resources/sw360.properties
Original file line number Diff line number Diff line change
Expand Up @@ -215,6 +215,7 @@ logout.redirect.url=
#list of predefined tags
project.tag=[]

rest.api.write.access.token.in.preferences=false
# Possible values are "ADMIN", "SW360_ADMIN", "CLEARING_ADMIN", "CLEARING_EXPERT", "ECC_ADMIN", "SECURITY_ADMIN", "USER"
# ADMIN by default has merge/split access
# Access follows isUserAtLeast(ROLE)
Expand Down

0 comments on commit 1abff27

Please sign in to comment.