Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ES-558] Update handles #1008

Open
wants to merge 61 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
05cb6a8
update handles doc
May 7, 2024
182e544
update handles doc
May 7, 2024
a3073cd
update handles doc
May 9, 2024
42be0d9
fixed review comments
May 9, 2024
d1a968b
fixed review comments
May 9, 2024
49fd982
fixed review comments
May 9, 2024
afa25c4
fixed review comments
May 9, 2024
35ef973
updated doc
May 13, 2024
5b5eb38
updated doc
May 13, 2024
d4e8947
changes for update handles
May 13, 2024
2c0806a
changes for update handles
May 13, 2024
5c1e107
changes for update handles
May 13, 2024
5a41346
changes for update handles
May 15, 2024
50ee5e7
changes for update handles
May 15, 2024
65eee51
updated the db scripts
May 15, 2024
db52021
updated code
May 15, 2024
29d582b
updated code
May 15, 2024
09b658a
updated code
May 16, 2024
f739f59
updated code
May 16, 2024
73c8a87
updated code
May 16, 2024
b636b75
updated code
May 16, 2024
b4c0c77
updated code
May 16, 2024
c1cb253
code changes for callback API
May 17, 2024
28cb675
code changes for callback API
May 17, 2024
b7ab567
updated controller name
May 17, 2024
598a530
update doc
May 20, 2024
48e25d1
added junit
May 20, 2024
10f17b1
added upgrade scripts
May 21, 2024
16f0425
added upgrade scripts
May 21, 2024
68d85ea
update author
May 21, 2024
c097773
update trim whitespace code
May 21, 2024
bd1a071
update enum
May 22, 2024
9066be0
update db upgrade script
May 22, 2024
7813194
update handle doc
May 22, 2024
a109dc6
rename upgrade db script
May 22, 2024
be203ea
added upgrade db script
May 22, 2024
1c67ef3
fixed review comments
May 27, 2024
8fd7d09
updated javadoc
May 27, 2024
3d976f6
updated code
May 28, 2024
259483b
updated push-trigger
May 28, 2024
b9b1931
testing issue with credentialrequeststatus table
Jun 4, 2024
782f8f8
testing issue with credentialrequeststatus table
Jun 4, 2024
ee2c828
testing issue with credentialrequeststatus table
Jun 5, 2024
841c792
added debug log
Jun 6, 2024
720ab29
fixed nullpointer issue
Jun 7, 2024
935cc50
fixed hash salt issue
Jun 7, 2024
23f454e
fixed test failure
Jun 7, 2024
1fef317
fixed build issue
Jun 7, 2024
3497f64
fixed build issue
Jun 7, 2024
57c7c71
fixed build issue
Jun 10, 2024
46a565c
[ES-558] Fixed build issue (#988)
RitikJain4108 Jun 7, 2024
69a4fee
[ES-558] Fixed build issue (#989)
RitikJain4108 Jun 10, 2024
71f0e20
updated cache name
Jun 12, 2024
f6b226c
fixed nullpointer issue
Jun 18, 2024
c7fbca8
revert hashing fix
Jun 19, 2024
7abd6c2
updated for new scenarios
Jun 26, 2024
0ca1094
updated for new scenarios
Jun 26, 2024
c514e26
updated for new scenarios
Jun 26, 2024
96425b0
revert back pom changes
Jul 2, 2024
955b807
revert ES-803 cache changes #992
Jul 2, 2024
c3d17dc
updated db scripts
Jul 2, 2024
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
1 change: 1 addition & 0 deletions .github/workflows/push-trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ on:
- 1.*
- develop
- MOSIP*
- ES-842

jobs:
build-maven-id-repository:
Expand Down
3 changes: 3 additions & 0 deletions db_release_scripts/mosip_idrepo/ddl/idrepo-handle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CREATE TABLE idrepo.handle(
uin_hash character varying NOT NULL,
handle character varying NOT NULL,
handle_hash character varying NOT NULL,
status character varying(32) NOT NULL,
cr_by character varying(256) NOT NULL,
cr_dtimes timestamp NOT NULL,
CONSTRAINT pk_handle PRIMARY KEY (id),
Expand All @@ -31,6 +32,8 @@ COMMENT ON COLUMN idrepo.handle.handle IS 'Handle : Unique username of the indiv
-- ddl-end --
COMMENT ON COLUMN idrepo.handle.handle_hash IS 'Handle Hash: Hash value of Unique username of the individual.';
-- ddl-end --
COMMENT ON COLUMN idrepo.handle.status IS 'Status: Current Status of the Handle.';
-- ddl-end --
COMMENT ON COLUMN idrepo.handle.cr_by IS 'Created By : ID or name of the user who create / insert record';
-- ddl-end --
COMMENT ON COLUMN idrepo.handle.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted';
Expand Down
3 changes: 3 additions & 0 deletions db_scripts/mosip_idrepo/ddl/idrepo-handle.sql
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ CREATE TABLE idrepo.handle(
uin_hash character varying NOT NULL,
handle character varying NOT NULL,
handle_hash character varying NOT NULL,
status character varying(32) NOT NULL,
cr_by character varying(256) NOT NULL,
cr_dtimes timestamp NOT NULL,
CONSTRAINT pk_handle PRIMARY KEY (id),
Expand All @@ -31,6 +32,8 @@ COMMENT ON COLUMN idrepo.handle.handle IS 'Handle : Unique username of the indiv
-- ddl-end --
COMMENT ON COLUMN idrepo.handle.handle_hash IS 'Handle Hash: Hash value of Unique username of the individual.';
-- ddl-end --
COMMENT ON COLUMN idrepo.handle.status IS 'Status: Current Status of the Handle.';
-- ddl-end --
COMMENT ON COLUMN idrepo.handle.cr_by IS 'Created By : ID or name of the user who create / insert record';
-- ddl-end --
COMMENT ON COLUMN idrepo.handle.cr_dtimes IS 'Created DateTimestamp : Date and Timestamp when the record is created/inserted';
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION'
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
\echo 'Upgrade Queries not required for transition from $CURRENT_VERSION to $UPGRADE_VERSION'
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- -------------------------------------------------------------------------------------------------
-- Database Name: mosip_idrepo
-- Purpose : Revoking Database alter scripts for release of ID Repository DB.
-- Create By : Ritik Jain
-- Created Date : May-2024
--
-- Modified Date Modified By Comments / Remarks
-- -------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------

\c mosip_idrepo sysadmin
---------------------------------------------------------------------------------------------------

ALTER TABLE idrepo.handle DROP COLUMN IF EXISTS status;

------------------------------------------------------------------------------------------------
16 changes: 16 additions & 0 deletions db_upgrade_scripts/mosip_idrepo/sql/1.2.1.0_to_1.2.2.0_upgrade.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
-- -------------------------------------------------------------------------------------------------
-- Database Name: mosip_idrepo
-- Purpose : Database alter scripts for release of ID Repository DB.
-- Create By : Ritik Jain
-- Created Date : May-2024
--
-- Modified Date Modified By Comments / Remarks
-- -------------------------------------------------------------------------------------------------
-------------------------------------------------------------------------------------------------------

\c mosip_idrepo sysadmin
---------------------------------------------------------------------------------------------------

ALTER TABLE idrepo.handle ADD COLUMN status character varying(32) NOT NULL DEFAULT 'ACTIVATED';

------------------------------------------------------------------------------------------------
21 changes: 19 additions & 2 deletions docs/design/handle_support.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,28 @@ As handles are revocable they provide strong privacy by default. If a user feels
4. Get the salt for the input handle and generate the selected handle salted hash.
5. Check if an entry exists with the same handle hash in the `mosip_idrepo.handle` table.
6. Fails the `add_identity` request if an entry exists.
7. Otherwise, create an identity with UIN and Create an entry in the `mosip_idrepo.handle` table for each selected handle.
7. Otherwise, create an identity with UIN and Create an entry in the `mosip_idrepo.handle` table for each selected handle with status `ACTIVATED`.
8. Issue credentials with the UIN. As part of handle support, we have made this issuance configurable.
9. Issue credentials with the handle for each selected handle.
* There were changes in IDA to support handle as a new IDType and also introduced regex-based handle validation.
* Changes in `update_identity` API: (Not implemented)
* Changes in `update_identity` API:
1. Identify if any handle is selected in the input.
2. Check if the selected handles are configured as a HANDLE in `identity_schema`(JSON schema validation).
3. If no handles are selected, proceed with step 6.
4. If selected, get the salt for the input handles and generate the selected handles salted hash.
5. Follow below operations in `mosip_idrepo.handle` table.
a) If the handle is selected and the same handle is mapped to DIFFERENT user then fail the `update_identity` request.
b) If the handle is selected and the same handle is mapped to SAME user then do nothing.
c) If the handle is selected and the handle does NOT EXIST in `mosip_idrepo.handle` table, create entry in handle table.
d) If there are any unselected handles (when compared with stored selectedHandles and input selectedHandles), mark the handle status as `DELETE` in the `mosip_idrepo.handle` table.
Note: Add `status` column in the `mosip_idrepo.handle` table.
6. Update identity data (demo, docs & bio) in the uin table.

In CredentialServiceManager, when we fetch the list of handles for a UIN to issue credentials:
1. Issue credential event to be raised if the handle status is `ACTIVATED`.
2. If the handle status is `DELETE`, then send `REMOVE_ID` event to IDA and mark the handle status as `DELETE_REQUESTED`.
Note: If the UIN will be blocked or deactivated, then revoke credentials for all selected handles for a UIN.
3. We should change in the IDA to acknowledge `REMOVE_ID` event to identity-service as `REMOVE_ID_STATUS` event. On receiving successful acknowledgment from `REMOVE_ID_STATUS` event, delete the entry from `mosip_idrepo.handle` table.

### How is the credential request ID created for handles?

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ public enum AuditEvents {

GET_RID_BY_INDIVIDUALID("IDR-026", "System Event"),

GET_DRAFT_UIN_REQUEST_RESPONSE("IDR-027", "System Event"),;
GET_DRAFT_UIN_REQUEST_RESPONSE("IDR-027", "System Event"),

REMOVE_ID_STATUS("IDR-028", "System Event");



Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package io.mosip.idrepository.core.constant;

/**
* @author Ritik Jain
*
*/
public enum HandleStatusLifecycle {
ACTIVATED, DELETE, DELETE_REQUESTED;
}
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,15 @@ public class IdRepoConstants {
public static final String VID_EVENT_CALLBACK_URL = "mosip.idrepo.websub.vid-credential-update.callback-url";

public static final String CREDENTIAL_STATUS_UPDATE_TOPIC = "mosip.idrepo.websub.credential-status-update.topic";


public static final String REMOVE_ID_STATUS_EVENT_TOPIC = "mosip.idrepo.websub.remove-id-status.topic";

public static final String REMOVE_ID_STATUS_EVENT_SECRET = "mosip.idrepo.websub.remove-id-status.secret";

public static final String REMOVE_ID_STATUS_EVENT_CALLBACK_RELATIVE_URL = "idrepo.websub.callback.remove-id-status.relative.url";

public static final String REMOVE_ID_STATUS_EVENT_CALLBACK_URL = "mosip.idrepo.websub.remove-id-status.callback-url";

public static final String FACE_EXTRACTION_FORMAT = "faceExtractionFormat";

public static final String IRIS_EXTRACTION_FORMAT = "irisExtractionFormat";
Expand Down Expand Up @@ -214,6 +222,9 @@ public class IdRepoConstants {
/** The Constant CREATE. */
public static final String CREATE = "create";

/** The Constant UPDATE. */
public static final String UPDATE = "update";

/** The Constant READ. */
public static final String READ = "read";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,9 @@ public class Handle implements HandleInfo {
@Column(name = "handle_hash")
private String handleHash;

@Column(name = "status")
private String status;

@Column(name = "cr_by")
private String createdBy;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@
import static io.mosip.idrepository.core.constant.IdRepoConstants.EXPIRY_TIMESTAMP;
import static io.mosip.idrepository.core.constant.IdRepoConstants.ID_HASH;
import static io.mosip.idrepository.core.constant.IdRepoConstants.ID_REPO;
import static io.mosip.idrepository.core.constant.IdRepoConstants.REMOVE_ID_STATUS_EVENT_CALLBACK_URL;
import static io.mosip.idrepository.core.constant.IdRepoConstants.REMOVE_ID_STATUS_EVENT_SECRET;
import static io.mosip.idrepository.core.constant.IdRepoConstants.REMOVE_ID_STATUS_EVENT_TOPIC;
import static io.mosip.idrepository.core.constant.IdRepoConstants.TRANSACTION_LIMIT;
import static io.mosip.idrepository.core.constant.IdRepoConstants.VID_EVENT_CALLBACK_URL;
import static io.mosip.idrepository.core.constant.IdRepoConstants.VID_EVENT_SECRET;
Expand Down Expand Up @@ -80,6 +83,15 @@ public class IdRepoWebSubHelper {
@Value("${" + VID_EVENT_CALLBACK_URL + "}")
private String vidEventUrl;

@Value("${" + REMOVE_ID_STATUS_EVENT_TOPIC + "}")
private String removeIdStatusEventTopic;

@Value("${" + REMOVE_ID_STATUS_EVENT_SECRET + "}")
private String removeIdStatusEventSecret;

@Value("${" + REMOVE_ID_STATUS_EVENT_CALLBACK_URL + "}")
private String removeIdStatusEventCallbackUrl;

/** The ida event type namespace. */
@Value("${id-repo-ida-event-type-namespace:mosip}")
private String idaEventTypeNamespace;
Expand Down Expand Up @@ -250,6 +262,23 @@ public void subscribeForVidEvent() {
}
}

public void subscribeForRemoveIdStatusEvent() {
try {
SubscriptionChangeRequest subscriptionRequest = new SubscriptionChangeRequest();
subscriptionRequest.setCallbackURL(removeIdStatusEventCallbackUrl);
subscriptionRequest.setHubURL(hubURL);
subscriptionRequest.setSecret(removeIdStatusEventSecret);
subscriptionRequest.setTopic(removeIdStatusEventTopic);
subscribe.subscribe(subscriptionRequest);
mosipLogger.info(IdRepoSecurityManager.getUser(), this.getClass().getCanonicalName(),
"subscribeForRemoveIdStatusEvent", "subscribed event topic: " + removeIdStatusEventTopic);
} catch (Exception e) {
mosipLogger.warn(IdRepoSecurityManager.getUser(), this.getClass().getCanonicalName(),
"subscribeForRemoveIdStatusEvent",
"Error subscribing topic: " + removeIdStatusEventTopic + "\n" + e.getMessage());
}
}

public void publishEvent(EventModel event) {
this.publishEvent(event.getTopic(), event);
}
Expand Down
Loading