Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public class PacketReaderController {
@Autowired
private PacketReaderService packetReaderService;

@PreAuthorize("hasAnyRole('DATA_READ')")
//@PreAuthorize("hasAnyRole('DATA_READ')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostsearchfield())")
@ResponseFilter
@PostMapping(path = "/searchField", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<FieldResponseDto> searchField(@RequestBody(required = true) RequestWrapper<FieldDto> fieldDto) {
Expand All @@ -61,7 +62,8 @@ public ResponseWrapper<FieldResponseDto> searchField(@RequestBody(required = tru
return response;
}

@PreAuthorize("hasAnyRole('DATA_READ')")
//@PreAuthorize("hasAnyRole('DATA_READ')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostsearchfields())")
@ResponseFilter
@PostMapping(path = "/searchFields", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<FieldResponseDto> searchFields(@RequestBody(required = true) RequestWrapper<FieldDtos> request) {
Expand All @@ -84,7 +86,8 @@ public ResponseWrapper<FieldResponseDto> searchFields(@RequestBody(required = tr
return response;
}

@PreAuthorize("hasAnyRole('DOCUMENT_READ')")
// @PreAuthorize("hasAnyRole('DOCUMENT_READ')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostdocument())")
@ResponseFilter
@PostMapping(path = "/document", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<Document> getDocument(@RequestBody(required = true) RequestWrapper<DocumentDto> request) {
Expand All @@ -99,7 +102,8 @@ public ResponseWrapper<Document> getDocument(@RequestBody(required = true) Reque
return response;
}

@PreAuthorize("hasAnyRole('BIOMETRIC_READ')")
// @PreAuthorize("hasAnyRole('BIOMETRIC_READ')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostbiometrics())")
@ResponseFilter
@PostMapping(path = "/biometrics", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<BiometricRecord> getBiometrics(@RequestBody(required = true) RequestWrapper<BiometricRequestDto> request) {
Expand All @@ -115,7 +119,8 @@ public ResponseWrapper<BiometricRecord> getBiometrics(@RequestBody(required = tr
return response;
}

@PreAuthorize("hasAnyRole('METADATA_READ')")
//@PreAuthorize("hasAnyRole('METADATA_READ')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostmetainfo())")
@ResponseFilter
@PostMapping(path = "/metaInfo", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<FieldResponseDto> getMetaInfo(@RequestBody(required = true) RequestWrapper<InfoDto> request) {
Expand All @@ -129,7 +134,8 @@ public ResponseWrapper<FieldResponseDto> getMetaInfo(@RequestBody(required = tru
return response;
}

@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
// @PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostaudits())")
@ResponseFilter
@PostMapping(path = "/audits", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<List<FieldResponseDto>> getAudits(@RequestBody(required = true) RequestWrapper<InfoDto> request) {
Expand All @@ -149,7 +155,8 @@ public ResponseWrapper<List<FieldResponseDto>> getAudits(@RequestBody(required =
return response;
}

@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
// @PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostvalidatepacket())")
@ResponseFilter
@PostMapping(path = "/validatePacket", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<ValidatePacketResponse> validatePacket(@RequestBody(required = true) RequestWrapper<InfoDto> request) {
Expand All @@ -161,8 +168,9 @@ public ResponseWrapper<ValidatePacketResponse> validatePacket(@RequestBody(requi
return response;
}

@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@ResponseFilter
//@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostgettags())")
@ResponseFilter
@PostMapping(path = "/getTags", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<TagResponseDto> getTags(
@RequestBody(required = true) RequestWrapper<TagRequestDto> request) {
Expand All @@ -174,7 +182,8 @@ public ResponseWrapper<TagResponseDto> getTags(
return response;
}

@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
// @PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostinfo())")
@ResponseFilter
@PostMapping(path = "/info", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<InfoResponseDto> info(@RequestBody(required = true) RequestWrapper<InfoRequestDto> request) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@ public class PacketWriterController {



@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@ResponseFilter
// @PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPutcreatepacket())")
@ResponseFilter
@PutMapping(path = "/createPacket", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<List<PacketInfo>> createPacket(@RequestBody(required = true) RequestWrapper<PacketDto> requestr) {

Expand All @@ -47,7 +48,8 @@ private ResponseWrapper getResponseWrapper() {
return response;
}

@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
//@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostaddtag())")
@ResponseFilter
@PostMapping(path = "/addTag", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<TagResponseDto> setTags(
Expand All @@ -59,7 +61,8 @@ public ResponseWrapper<TagResponseDto> setTags(
return response;
}

@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
// @PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostaddorupdatetag())")
@ResponseFilter
@PostMapping(path = "/addOrUpdateTag", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
public ResponseWrapper<TagResponseDto> updateTags(@RequestBody(required = true) RequestWrapper<TagDto> tagRequest) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package io.mosip.commons.packetmanager.dto;

import java.util.List;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.stereotype.Component;

import lombok.Getter;
import lombok.Setter;


@Component("authorizedRoles")
@ConfigurationProperties(prefix = "mosip.role.packetmanager")
@Getter
@Setter
public class AuthorizedRolesDTO {

private List<String> postsearchfield;

private List<String> postsearchfields;

private List<String> postdocument;

private List<String> postbiometrics;

private List<String> postmetainfo;

private List<String> postaudits;

private List<String> postvalidatepacket;

private List<String> postgettags;

private List<String> postinfo;

private List<String> postcreatepacket;

private List<String> postaddtag;

private List<String> postaddorupdatetag;

private List<String> postdeletetag;


}
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,18 @@ mosip.kernel.machineid.length=5
masterdata.registerdevice.timestamp.validate=+5
mosip.kernel.applicant.type.age.limit = 5

#adding commons-packet-manager properties
mosip.role.packetmanager.postcreatepacket=REGISTRATION_PROCESSOR
mosip.role.packetmanager.postaddtag=REGISTRATION_PROCESSOR
mosip.role.packetmanager.postaddorupdatetag=REGISTRATION_PROCESSOR
mosip.role.packetmanager.postdeletetag=REGISTRATION_PROCESSOR
mosip.role.packetmanager.postinfo=REGISTRATION_PROCESSOR
mosip.role.packetmanager.postgettags=REGISTRATION_PROCESSOR
mosip.role.packetmanager.postvalidatepacket=REGISTRATION_PROCESSOR
mosip.role.packetmanager.postaudits=REGISTRATION_PROCESSOR
mosip.role.packetmanager.postmetainfo=METADATA_READ
mosip.role.packetmanager.postbiometrics=BIOMETRIC_READ
mosip.role.packetmanager.postdocument=DOCUMENT_READ
mosip.role.packetmanager.postsearchfields=DATA_READ
mosip.role.packetmanager.postsearchfield=DATA_READ