Skip to content

Commit

Permalink
Cherry picked fixes from develop to Release 1.x.x (#69)
Browse files Browse the repository at this point in the history
* ES-757 Error handler for PENDING status on sign up page (#65)

Signed-off-by: pr <[email protected]>

* ES-753 (#67)

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

* Issues with cached methods found during redis integration fixed (#68)

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

---------

Signed-off-by: pr <[email protected]>
Signed-off-by: ase-101 <[email protected]>
Co-authored-by: panharith-0118 <[email protected]>
  • Loading branch information
ase-101 and panharith-0118 authored Feb 12, 2024
1 parent 23634bc commit a66f263
Show file tree
Hide file tree
Showing 13 changed files with 308 additions and 19 deletions.
56 changes: 56 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,61 @@

signup-service is part of the esignet modules, but has a separate Helm chart so as to install and manage it in a completely independent namespace.

Below diagram depicts the high level deployment architecture for signup service with MOSIP ID-repo.

![](docs/signup-with-mosip-id-repo.png)

### Configurations
Signup service and signup UI currently supports default [ID schema](docs/id-schema.json) only.

**Note:**
Work is in progress to support any ID schema and also to connect with any registry services.

With respect to the default ID schema, below MOSIP configurations are required to be updated.

#### admin-default.properties
``
mosip.admin.masterdata.lang-code=eng,khm
``

#### application-default.properties
```
mosip.mandatory-languages=eng,khm
mosip.optional-languages=
mosip.default.template-languages=eng,khm
```

#### id-authentication-default.properties
```
request.idtypes.allowed=UIN,HANDLE
request.idtypes.allowed.internalauth=UIN
ida.mosip.external.auth.filter.classes.in.execution.order=io.mosip.authentication.hotlistfilter.impl.PartnerIdHotlistFilterImpl,io.mosip.authentication.hotlistfilter.impl.IndividualIdHotlistFilterImpl,io.mosip.authentication.hotlistfilter.impl.DeviceProviderHotlistFilterImpl,io.mosip.authentication.hotlistfilter.impl.DeviceHotlistFilterImpl,io.mosip.authentication.authtypelockfilter.impl.AuthTypeLockFilterImpl
mosip.ida.handle-types.regex={ '@phone' : '^\\+91[1-9][0-9]{7,9}@phone$' }
```

#### id-repository-default.properties
```
mosip.idrepo.credential.request.enable-convention-based-id=true
mosip.idrepo.identity.disable-uin-based-credential-request=true
mosip.idrepo.vid.disable-support=true
mosip.identity.fieldid.handle-postfix.mapping={'phone':'@phone'}
```

#### kernel-default.properties
``
mosip.kernel.sms.country.code=+91
``



## Installing in k8s cluster using helm
### Pre-requisites
1. Set the kube config file of the Mosip cluster having dependent services is set correctly in PC.
Expand Down Expand Up @@ -53,6 +108,7 @@ signup-service is part of the esignet modules, but has a separate Helm chart so
cd helm
./restart-all.sh
```


## APIs
API documentation is available [here](https://mosip.stoplight.io/docs/identity-provider/branches/signupV1/t9tvfbteqqokf-e-signet-signup-portal-ap-is).
Expand Down
193 changes: 193 additions & 0 deletions docs/id-schema.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,193 @@
{
"$schema": "http://json-schema.org/draft-07/schema#",
"description": "Identity schema for sign up",
"additionalProperties": false,
"title": "signup identity",
"type": "object",
"definitions": {
"simpleType": {
"uniqueItems": true,
"additionalItems": false,
"type": "array",
"items": {
"additionalProperties": false,
"type": "object",
"required": [
"language",
"value"
],
"properties": {
"language": {
"type": "string"
},
"value": {
"type": "string"
}
}
}
},
"documentType": {
"additionalProperties": false,
"type": "object",
"properties": {
"format": {
"type": "string"
},
"type": {
"type": "string"
},
"value": {
"type": "string"
}
}
},
"biometricsType": {
"additionalProperties": false,
"type": "object",
"properties": {
"format": {
"type": "string"
},
"version": {
"type": "number",
"minimum": 0
},
"value": {
"type": "string"
}
}
},
"hashType": {
"additionalProperties": false,
"type": "object",
"properties": {
"hash": {
"type": "string"
},
"salt": {
"type": "string"
}
}
}
},
"properties": {
"identity": {
"additionalProperties": false,
"type": "object",
"required": [
"IDSchemaVersion",
"fullName",
"phone",
"password",
"preferredLang",
"registrationType"
],
"properties": {
"UIN": {
"bioAttributes": [],
"fieldCategory": "none",
"format": "none",
"type": "string",
"fieldType": "default"
},
"IDSchemaVersion": {
"bioAttributes": [],
"fieldCategory": "none",
"format": "none",
"type": "number",
"fieldType": "default",
"minimum": 0
},
"selectedHandles" : {
"fieldCategory": "none",
"format": "none",
"type": "array",
"items" : { "type" : "string" },
"fieldType": "default"
},
"fullName": {
"bioAttributes": [],
"validators": [
{
"validator": "^(?=.{3,50}$).",
"arguments": [],
"type": "regex"
}
],
"fieldCategory": "pvt",
"format": "none",
"fieldType": "default",
"$ref": "#/definitions/simpleType"
},
"phone": {
"bioAttributes": [],
"validators": [
{
"validator": "^[+]91([0-9]{8,9})$",
"arguments": [],
"type": "regex"
}
],
"fieldCategory": "pvt",
"format": "none",
"type": "string",
"fieldType": "default",
"requiredOn" : "",
"handle" : true
},
"password": {
"bioAttributes": [],
"validators": [],
"fieldCategory": "pvt",
"format": "none",
"fieldType": "default",
"$ref": "#/definitions/hashType"
},
"preferredLang": {
"bioAttributes": [],
"validators": [
{
"validator": "(^eng$)",
"arguments": [],
"type": "regex"
}
],
"fieldCategory": "pvt",
"format": "none",
"fieldType": "default",
"type": "string"
},
"registrationType": {
"bioAttributes": [],
"validators": [
{
"validator": "^L[1-2]{1}$",
"arguments": [],
"type": "regex"
}
],
"fieldCategory": "pvt",
"format": "none",
"fieldType": "default",
"type": "string"
},
"phoneVerified": {
"bioAttributes": [],
"validators": [],
"fieldCategory": "pvt",
"format": "none",
"fieldType": "default",
"type": "boolean"
},
"updatedAt": {
"bioAttributes": [],
"validators": [],
"fieldCategory": "pvt",
"format": "none",
"fieldType": "default",
"type": "number"
}
}
}
}
}
Binary file added docs/signup-with-mosip-id-repo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package io.mosip.signup.controllers;

import io.micrometer.core.annotation.Counted;
import io.micrometer.core.annotation.Timed;
import io.mosip.esignet.core.dto.RequestWrapper;
import io.mosip.esignet.core.dto.ResponseWrapper;
import io.mosip.esignet.core.util.IdentityProviderUtil;
Expand Down Expand Up @@ -70,6 +72,8 @@ public ResponseWrapper<VerifyChallengeResponse> verifyChallenge(@Valid @RequestB
return responseWrapper;
}


@Timed(value = "register.timer", percentiles = {0.95, 0.99})
@PostMapping("/register")
public ResponseWrapper<RegisterResponse> register(@Valid @RequestBody RequestWrapper<RegisterRequest> requestWrapper,
@Valid @NotBlank(message = ErrorConstants.INVALID_TRANSACTION)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package io.mosip.signup.controllers;


import io.micrometer.core.annotation.Timed;
import io.mosip.esignet.core.dto.RequestWrapper;
import io.mosip.esignet.core.dto.ResponseWrapper;
import io.mosip.esignet.core.util.IdentityProviderUtil;
Expand Down Expand Up @@ -43,6 +44,7 @@ public ResponseWrapper<SettingsResponse> getSignUpDetails() {
return responseWrapper;
}

@Timed(value = "resetpwd.timer", percentiles = {0.95, 0.99})
@PostMapping("/reset-password")
public ResponseWrapper<RegistrationStatusResponse> resetPassword(@Valid @RequestBody RequestWrapper<ResetPasswordRequest> requestWrapper,
@Valid @NotBlank(message = ErrorConstants.INVALID_TRANSACTION)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ public class CacheUtilService {
CacheManager cacheManager;

//---Setter---
@Cacheable(value = SignUpConstants.CHALLENGE_GENERATED, key = "#transactionId")
public RegistrationTransaction setChallengeGeneratedTransaction(String transactionId,
RegistrationTransaction registrationTransaction) {
return registrationTransaction;
}

@CacheEvict(value = SignUpConstants.CHALLENGE_GENERATED, key = "#transactionId")
@Cacheable(value = SignUpConstants.CHALLENGE_VERIFIED, key = "#verifiedTransactionId")
Expand All @@ -36,14 +31,15 @@ public RegistrationTransaction setChallengeVerifiedTransaction(String transactio
}

@CacheEvict(value = SignUpConstants.CHALLENGE_VERIFIED, key = "#transactionId")
@CachePut(value = SignUpConstants.STATUS_CHECK, key = "#transactionId")
@Cacheable(value = SignUpConstants.STATUS_CHECK, key = "#transactionId")
public RegistrationTransaction setStatusCheckTransaction(String transactionId,
RegistrationTransaction registrationTransaction) {
return registrationTransaction;
}

@CacheEvict(value = SignUpConstants.CHALLENGE_GENERATED, key = "#transactionId")
@Cacheable(value = SignUpConstants.BLOCKED_IDENTIFIER, key = "#key")
public String blockIdentifier(String key, String value) {
public String blockIdentifier(String transactionId, String key, String value) {
return value;
}

Expand All @@ -52,11 +48,26 @@ public String setSecretKey(String key, String secretKey) {
return secretKey;
}

@Cacheable(value = SignUpConstants.KEY_ALIAS, key = "#key")
@CachePut(value = SignUpConstants.KEY_ALIAS, key = "#key")
public String setActiveKeyAlias(String key, String alias) {
return alias;
}


//----- cache update is separated
//----- we are not using @cacheput as @cacheput extends the TTL on cache entry

public RegistrationTransaction createUpdateChallengeGeneratedTransaction(String transactionId,
RegistrationTransaction registrationTransaction) {
cacheManager.getCache(SignUpConstants.CHALLENGE_GENERATED).put(transactionId, registrationTransaction);
return registrationTransaction;
}

public void updateStatusCheckTransaction(String transactionId,
RegistrationTransaction registrationTransaction) {
cacheManager.getCache(SignUpConstants.STATUS_CHECK).put(transactionId, registrationTransaction);
}

//---Getter---
public RegistrationTransaction getChallengeGeneratedTransaction(String transactionId) {
return cacheManager.getCache(SignUpConstants.CHALLENGE_GENERATED).get(transactionId, RegistrationTransaction.class);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.mosip.signup.services;

import io.micrometer.core.annotation.Timed;
import io.mosip.esignet.core.util.IdentityProviderUtil;
import io.mosip.signup.dto.*;
import io.mosip.signup.exception.SignUpException;
Expand Down Expand Up @@ -39,6 +40,7 @@ public String generateChallenge(RegistrationTransaction transaction) throws Sign
throw new SignUpException(ErrorConstants.UNSUPPORTED_CHALLENGE_TYPE);
}

@Timed(value = "generateotp.api.timer", percentiles = {0.95, 0.99})
private String generateOTPChallenge(String challengeTransactionId) {
OtpRequest otpRequest = new OtpRequest();
otpRequest.setKey(challengeTransactionId);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package io.mosip.signup.services;

import io.micrometer.core.annotation.Timed;
import io.mosip.esignet.api.spi.CaptchaValidator;
import io.mosip.signup.dto.ReCaptchaResponse;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -30,6 +31,7 @@ public class GoogleRecaptchaValidatorService implements CaptchaValidator {
@Autowired
private RestTemplate restTemplate;

@Timed(value = "validatecaptcha.api.timer", percentiles = {0.95, 0.99})
@Override
public boolean validateCaptcha(String captchaToken) {

Expand Down
Loading

0 comments on commit a66f263

Please sign in to comment.