ЕСОЗ - публічна документація
Sign up via id.gov.ua
Purpose
Register users in Cabinet via integrated system of digital identification.
Endpoints used for integration is described here
Sequence diagram
Auth Flow
Front-end: ReCaptcha validation
Front-end render reCAPTCHA form and user interact with it. Result of reCAPTCHA validation is token, that used for Auth Request as ID.
Front-end: Initialize auth request
Create new auth request in short-life term storage with auth data (client_id
, redirect_uri,
scope
).
ReCAPTCHA token must used as ID for auth request.
Auth request used for security reasons and helps to prevent CSRF with a white list of auth URLs.
Front-end: Generate link and redirect to id.gov.ua login page
Front-end generates link and redirects client to id.gov.ua login page with next params:
parameter | description |
---|---|
redirect_uri | Mithril redirect endpoint |
state | ReCAPTCHA token, Auth request ID that used for completing auth process. |
Mithril: Get User info from id.gov.ua
After successful login via id.gov.ua, clients browser redirected to Mithril endpoint with authorization code and state.
- Get AuthRequest from in-memory DB
- Validate AuthRequest:
- if AuthRequest not found - return 401 error
- if AuthRequest expired - return 401 error
- Validate reCAPTCHA token (state):
- if invalid - return 401 error
- Exchange authorization code to access token in id.gov.ua (API documentation)
- Get User Info (tax_id, first_name, last_name, email) by access token from id.gov.ua (API documentation)
Mithril: Create UserRequest
- Search user in
users
table bytax_id
- if user found:
- Search person in MPI by user.person_id
- if person found → /wiki/spaces/EH/pages/583403011
- if person not found → continue registration
- if user not found → continue registration
- if user found:
- Create UserRequest with
tax_id
,first_name
,last_name
,email
fields in temporary DB - Generate JWT with UserRequest id (
user_request_id
)
- Redirects to Front-end Sign-Up page with JWT
Front-end: Registration form
Front-end renders registration from with prefilled data, that fetched from Mithril (Apiary) by JWT
Mithril: Get UserRequest
- Validate JWT expiration and claim
- if JWT is invalid - return 401 error
- Get
user_request_id
from JWT - Search UserRequest by
user_request_id
- if NOT found - return 404 error
- if found - validate expiration
- if expired - return 410 error
Front-end: Register Patient
Send registration form to IL
IL: Create Person
Process of person creation with id.gov.ua is very close to /wiki/spaces/PCAB/pages/583402002
The difference is that the form data is not signed and users personal data should be verified using UserRequest in Mithril, and not with DS
- Validate JWT expiration and claim
- if JWT is invalid - return 401 error
- Get
user_request_id
from JWT - Get UserRequest from Mithril (Apiary)
- if UserRequest expired or not found - return 409 error
- Ignore
preferred_way_communication
from input and set it tophone
- Validate Form input via Json Schema (described in /wiki/spaces/PCAB/pages/583402002)
- Create User in MPI (described in /wiki/spaces/PCAB/pages/583402002)
- Create Token for Consent dialog
- Send back created User, Patient and Token
Front-end: Consent page and Cabinet
- Show to user Consent Page with scopes that application requests.
- If user grant access, create code grant token in Mithril (Apiary)
- Redirect client to
redirect_uri
from previous response - Application exchange code grant to access token (Apiary)
- Redirect to Cabinet Landing Page
ЕСОЗ - публічна документація