Compare commits
1 Commits
main
...
RED-7175-8
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
fb79f84d49 |
@ -60,4 +60,9 @@ public interface TenantsResource {
|
|||||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||||
DeploymentKeyResponse getDeploymentKey(@PathVariable(TENANT_ID_PARAM) String tenantId);
|
DeploymentKeyResponse getDeploymentKey(@PathVariable(TENANT_ID_PARAM) String tenantId);
|
||||||
|
|
||||||
|
@PostMapping(value = "/tenants/{tenantId}/appPrefix", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@Operation(summary = "Set custom app prefix for existing tenant", description = "None")
|
||||||
|
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||||
|
void updateAppPrefix(@PathVariable("tenantId") String tenantId, @RequestBody String appPrefix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -68,4 +68,10 @@ public interface InternalTenantsResource {
|
|||||||
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||||
DeploymentKeyResponse getDeploymentKey(@PathVariable(TENANT_ID_PARAM) String tenantId);
|
DeploymentKeyResponse getDeploymentKey(@PathVariable(TENANT_ID_PARAM) String tenantId);
|
||||||
|
|
||||||
|
|
||||||
|
@PostMapping(value = "/tenants/{tenantId}/appPrefix", consumes = MediaType.APPLICATION_JSON_VALUE)
|
||||||
|
@Operation(summary = "Set custom app prefix for existing tenant", description = "None")
|
||||||
|
@ApiResponses(value = {@ApiResponse(responseCode = "200", description = "OK")})
|
||||||
|
void updateAppPrefix(@PathVariable("tenantId") String tenantId, @RequestBody String appPrefix);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -81,4 +81,13 @@ public class TenantsController implements TenantsResource, PublicResource {
|
|||||||
return new DeploymentKeyResponse(deploymentKeyService.getDeploymentKey(tenantId));
|
return new DeploymentKeyResponse(deploymentKeyService.getDeploymentKey(tenantId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@PreAuthorize("hasAuthority('" + UPDATE_TENANT + "')")
|
||||||
|
public void updateAppPrefix(@PathVariable(TENANT_ID_PARAM) String tenantId,
|
||||||
|
@RequestBody String appPrefix) {
|
||||||
|
|
||||||
|
tenantManagementService.updateAppPrefix(tenantId, appPrefix);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -1,8 +1,11 @@
|
|||||||
package com.knecon.fforesight.tenantusermanagement.controller.internal;
|
package com.knecon.fforesight.tenantusermanagement.controller.internal;
|
||||||
|
|
||||||
|
import static com.knecon.fforesight.tenantusermanagement.permissions.UserManagementPermissions.UPDATE_TENANT;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import org.springframework.http.HttpStatus;
|
import org.springframework.http.HttpStatus;
|
||||||
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.web.bind.annotation.PathVariable;
|
import org.springframework.web.bind.annotation.PathVariable;
|
||||||
import org.springframework.web.bind.annotation.RequestBody;
|
import org.springframework.web.bind.annotation.RequestBody;
|
||||||
import org.springframework.web.bind.annotation.RestController;
|
import org.springframework.web.bind.annotation.RestController;
|
||||||
@ -76,4 +79,11 @@ public class InternalTenantsController implements InternalTenantsResource, Inter
|
|||||||
return new DeploymentKeyResponse(deploymentKeyService.getDeploymentKey(tenantId));
|
return new DeploymentKeyResponse(deploymentKeyService.getDeploymentKey(tenantId));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateAppPrefix(@PathVariable(TENANT_ID_PARAM) String tenantId,
|
||||||
|
@RequestBody String appPrefix) {
|
||||||
|
|
||||||
|
tenantManagementService.updateAppPrefix(tenantId, appPrefix);
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -178,7 +178,13 @@ public class TenantManagementService implements TenantProvider {
|
|||||||
|
|
||||||
private String buildIndexPrefix(String tenantId) {
|
private String buildIndexPrefix(String tenantId) {
|
||||||
|
|
||||||
return tenantUserManagementProperties.getAppPrefix() + "_" + tenantId;
|
return buildIndexPrefix(tenantId, tenantUserManagementProperties.getAppPrefix());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private String buildIndexPrefix(String tenantId, String appPrefix) {
|
||||||
|
|
||||||
|
return appPrefix + "_" + tenantId;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -581,4 +587,20 @@ public class TenantManagementService implements TenantProvider {
|
|||||||
realmService.realm(MASTER_REALM).update(realmRepresentation);
|
realmService.realm(MASTER_REALM).update(realmRepresentation);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public void updateAppPrefix(String tenantId, String appPrefix) {
|
||||||
|
|
||||||
|
if (appPrefix == null || appPrefix.isEmpty()) {
|
||||||
|
throw new ResponseStatusException(HttpStatus.BAD_REQUEST, "App prefix cannot be empty.");
|
||||||
|
}
|
||||||
|
|
||||||
|
var tenant = tenantRepository.findById(tenantId);
|
||||||
|
if (tenant.isPresent()) {
|
||||||
|
tenantUserManagementProperties.setAppPrefix(buildIndexPrefix(tenantId, appPrefix));
|
||||||
|
} else {
|
||||||
|
throw new ResponseStatusException(HttpStatus.NOT_FOUND, "Tenant does not exist");
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user