Skip to content

Commit

Permalink
ES-842 fix during the review (mosip#338)
Browse files Browse the repository at this point in the history
* ES-842 fix during the review

Signed-off-by: ase-101 <[email protected]>

* ES-842 fix during the review

Signed-off-by: ase-101 <[email protected]>

* ES-842 fix during the review

Signed-off-by: ase-101 <[email protected]>

---------

Signed-off-by: ase-101 <[email protected]>
  • Loading branch information
ase-101 authored Sep 4, 2024
1 parent 7b064a4 commit 8d47e99
Show file tree
Hide file tree
Showing 17 changed files with 738 additions and 195 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,5 @@
public class IdentityVerificationDto {

private String stepCode;
private String disabilityType;
private List<FrameDetail> frames;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
/*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at https://mozilla.org/MPL/2.0/.
*/
package io.mosip.signup.api.dto;

import lombok.Data;

@Data
public class IdentityVerificationInitDto {

private String individualId;
private String disabilityType;
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import java.util.Map;

@Data
public class VerifiedResult {
public class VerificationResult {

private VerificationStatus status;
private Map<String, VerificationDetail> verifiedClaims;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
package io.mosip.signup.api.spi;

import io.mosip.signup.api.dto.IdentityVerificationDto;
import io.mosip.signup.api.dto.IdentityVerificationInitDto;
import io.mosip.signup.api.dto.IdentityVerificationResult;
import io.mosip.signup.api.dto.VerifiedResult;
import io.mosip.signup.api.dto.VerificationResult;
import io.mosip.signup.api.exception.IdentityVerifierException;
import io.mosip.signup.api.util.ProcessType;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -50,6 +51,14 @@ public final boolean isEndStep(String stepCode) {
*/
public abstract List<ProcessType> getSupportedProcessTypes();


/**
* Initialize the transaction with individualId and the disability type (if any)
* @param transactionId
* @param identityVerificationInitDto
*/
public abstract void initialize(String transactionId, IdentityVerificationInitDto identityVerificationInitDto);

/**
* Verify the input frames based on the provided step code. TransactionId should be used to maintain the state of the
* verification process.
Expand All @@ -69,5 +78,5 @@ public final boolean isEndStep(String stepCode) {
* @return
* @throws IdentityVerifierException
*/
public abstract VerifiedResult getVerifiedResult(String transactionId) throws IdentityVerifierException;
public abstract VerificationResult getVerificationResult(String transactionId) throws IdentityVerifierException;
}
69 changes: 52 additions & 17 deletions signup-service/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Signup service is a spring boot application with endpoints to
3. Register user with verified transaction
4. Check registration status
5. Reset the password of the registered user
6. Websocket handler and endpoints to support video identity verification process.

Signup service connects to MOSIP IDRepo Identity service to register the verified user as an identity record.
ID Repo identity service publishes the registered identity to MOSIP IDA. This enables authentication with the registered
Expand All @@ -19,21 +20,47 @@ the latest status from server after every configured interval from signup UI.

Registration flow:

| Endpoint | Cache | Evict |
|-------------------|----------------------------------------------------------------------|-----------------------------------------------------|
| generateChallenge | challenge-generated (k: transactionId, v: SignupTransaction) | |
| verifyChallenge | challenge-verified (k: verified-transactionId, v: SignupTransaction) | challenge-generated (k: transactionId, v: SignupTransaction) |
| register | status-check (k: verified-transactionId, v: SignupTransaction) | challenge-verified (k: verified-transactionId, v: SignupTransaction) |
| status | status-check (k: verified-transactionId, v: SignupTransaction) | |
| Endpoint | Cache | Evict |
|-------------------|----------------------------------------------------------------------|----------------------------------------------------------------------|
| generateChallenge | challenge_generated (k: transactionId, v: SignupTransaction) | |
| verifyChallenge | challenge_verified (k: verified-transactionId, v: SignupTransaction) | challenge_generated (k: transactionId, v: SignupTransaction) |
| register | status_check (k: verified-transactionId, v: SignupTransaction) | challenge_verified (k: verified-transactionId, v: SignupTransaction) |
| status | status_check (k: verified-transactionId, v: SignupTransaction) | |

Reset Password flow:

| Endpoint | Cache | Evict |
|-------------------|----------------------------------------------------------------------------|-----------------------------------------------------|
| generateChallenge | challenge-generated (k: transactionId, v: SignupTransaction) | |
| verifyChallenge | challenge-verified (k: verified-transactionId, v: SignupTransaction) | challenge-generated (k: transactionId, v: SignupTransaction) |
| resetPassword | status-check (k: verified-transactionId, v: SignupTransaction) | challenge-verified (k: verified-transactionId, v: SignupTransaction) |
| status | status-check (k: verified-transactionId, v: SignupTransaction) | |
| Endpoint | Cache | Evict |
|-------------------|----------------------------------------------------------------------|----------------------------------------------------------------------|
| generateChallenge | challenge_generated (k: transactionId, v: SignupTransaction) | |
| verifyChallenge | challenge_verified (k: verified-transactionId, v: SignupTransaction) | challenge_generated (k: transactionId, v: SignupTransaction) |
| resetPassword | status_check (k: verified-transactionId, v: SignupTransaction) | challenge_verified (k: verified-transactionId, v: SignupTransaction) |
| status | status_check (k: verified-transactionId, v: SignupTransaction) | |


Identity Verification flow:

| Endpoint | Cache | Evict |
|---------------------------------|--------------------------------------------------------------------------|------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|
| identity-verification | identity_verification (k: transactionId, v: IdentityVerificationTransaction) | |
| slot | slot_allotted (k: transactionId, v: IdentityVerificationTransaction) | identity_verification (k: transactionId, v: IdentityVerificationTransaction) |
| /ws | verififed_slot (k: slotId, v: IdentityVerificationTransaction) | slot_allotted (k: transactionId, v: IdentityVerificationTransaction) |
| process-frame | verififed_slot (k: slotId, v: IdentityVerificationTransaction) | |
| /topic/slotId (STOMP - publish) | verified_slot (k: slotId, v: IdentityVerificationTransaction) | |
| Event - WS connect | slots_connected(connection-id) | |
| Event - WS disconnect | | slot_allotted (k: transactionId, v: IdentityVerificationTransaction) <br/>verififed_slot (k: slotId, v: IdentityVerificationTransaction) <br/>slots_connected(connection-id) |


> Note: slot_connected is a HSET in redis
>
> slot_connected "connection-id-1" "connected-time-epoch-1" "connection-id-2" "connected-time-epoch-2"
>
> On every scheduled interval `mosip.signup.slot.cleanup-cron` we run LUA script to remove expired connection-ids from slot_connected HSET cache.
>
> TTL for each connection-id in the slot_connected HSET is defined -> `mosip.signup.slot.expire-in-seconds`
>
> To get the current count of slots connected, we execute HLEN command on slot_connected cache.
>
> Note: The connection-id is concatenation of transactionId and slotId with a separator.

## Build & run (for developers)
Expand All @@ -46,13 +73,21 @@ The project requires JDK 11.
```
$ docker build -f Dockerfile
```
3. Run with IntelliJ IDEA
3. Run with IntelliJ IDEA
3.1 Right click on parent POM file (pom.xml) and click on button "Add as Maven Project".
3.1 Right click on parent POM file (pom.xml) and click on button "Add as Maven Project".
3.2 Add below dependency in the signup-service pom.xml
3.2 Download kernel-auth-adapter-1.2.1-es-SNAPSHOT.jar file from [here](https://oss.sonatype.org/#nexus-search;gav~io.mosip.kernel~kernel-auth-adapter~~~~kw,versionexpand).
```
<dependency>
<groupId>io.mosip.kernel</groupId>
<artifactId>kernel-auth-adapter-lite</artifactId>
<version>1.2.0.1-B4</version>
</dependency>
```
3.3 Add that file to "signup-service" in Project Structure settings of IntelliJ, and Apply.
3.3 Add that file to "signup-service" in Project Structure settings of IntelliJ, and Apply.
3.4 right click on file signup-service/src/main/java/io/mosip/signup/SignUpServiceApplication.java and click on Run
3.4 Open signup-service/src/main/java/io/mosip/signup/SignUpServiceApplication.java and click on Run
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
package io.mosip.signup.config;

import io.mosip.signup.services.IdentityVerificationHandshakeHandler;
import io.mosip.signup.services.WebSocketHandshakeHandler;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.config.MessageBrokerRegistry;
Expand All @@ -18,7 +18,7 @@
public class WebSocketConfig implements WebSocketMessageBrokerConfigurer {

@Autowired
private IdentityVerificationHandshakeHandler identityVerificationHandshakeHandler;
private WebSocketHandshakeHandler webSocketHandshakeHandler;

@Override
public void configureMessageBroker(MessageBrokerRegistry registry) {
Expand All @@ -29,6 +29,6 @@ public void configureMessageBroker(MessageBrokerRegistry registry) {
@Override
public void registerStompEndpoints(StompEndpointRegistry registry) {
//By default, only same origin requests are allowed, should take the origin from properties
registry.addEndpoint("/ws").setAllowedOrigins("*").setHandshakeHandler(identityVerificationHandshakeHandler);
registry.addEndpoint("/ws").setAllowedOrigins("*").setHandshakeHandler(webSocketHandshakeHandler);
}
}
Loading

0 comments on commit 8d47e99

Please sign in to comment.