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 @@ -53,7 +53,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)
@Operation(summary = "searchField", description = "searchField", tags = { "packet-reader-controller" })
Expand All @@ -77,7 +78,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)
@Operation(summary = "searchFields", description = "searchFields", tags = { "packet-reader-controller" })
Expand Down Expand Up @@ -106,7 +108,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)
@Operation(summary = "getDocument", description = "getDocument", tags = { "packet-reader-controller" })
Expand All @@ -127,7 +130,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)
@Operation(summary = "getBiometrics", description = "getBiometrics", tags = { "packet-reader-controller" })
Expand All @@ -149,7 +153,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)
@Operation(summary = "getMetaInfo", description = "getMetaInfo", tags = { "packet-reader-controller" })
Expand All @@ -169,7 +174,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)
@Operation(summary = "getAudits", description = "getAudits", tags = { "packet-reader-controller" })
Expand All @@ -195,7 +201,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)
@Operation(summary = "validatePacket", description = "validatePacket", tags = { "packet-reader-controller" })
Expand All @@ -213,8 +220,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)
@Operation(summary = "getTags", description = "getTags", tags = { "packet-reader-controller" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"),
Expand All @@ -231,7 +239,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)
@Operation(summary = "info", description = "info", tags = { "packet-reader-controller" })
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ public class PacketWriterController {
@Autowired
private PacketWriterService packetWriterService;

@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)
@Operation(summary = "createPacket", description = "createPacket", tags = { "packet-writer-controller" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"),
Expand All @@ -66,7 +67,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)
@Operation(summary = "setTags", description = "setTags", tags = { "packet-writer-controller" })
Expand All @@ -84,7 +86,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)
@Operation(summary = "updateTags", description = "updateTags", tags = { "packet-writer-controller" })
Expand All @@ -100,8 +103,9 @@ public ResponseWrapper<TagResponseDto> updateTags(@RequestBody(required = true)
response.setResponse(tagResponse);
return response;
}
@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
//@PreAuthorize("hasAnyRole('REGISTRATION_PROCESSOR')")
@ResponseFilter
@PreAuthorize("hasAnyRole(@authorizedRoles.getPostdeletetag())")
@PostMapping(path = "/deleteTag", consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
@Operation(summary = "deleteTags", description = "deleteTags", tags = { "packet-writer-controller" })
@ApiResponses(value = { @ApiResponse(responseCode = "200", description = "OK"),
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 @@ -39,3 +39,17 @@ packetmanager.default.read.strategy=
packetmanager.default.priority=
mosip.kernel.auth.appids.realm.map={prereg:'preregistration',ida:'mosip',registrationclient:'mosip',regproc:'mosip',partner:'mosip',resident:'mosip'}

#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