Registrant Authentication - OIDC Widget

Step-1 - Widget calls Registry API — /registrant-authentication/start-authentication-transaction
The Widget is not the component that is the true owner of the authentication-transaction. The true ownership, instead lies with the Registry Server side.
Step-2 - Start Auth_Transaction API
The API receives this call and starts the Authentication Transaction. It creates an Auth-Transaction object.
To create this Auth-Transaction object, the server side relies on some configurations (configuration tables) with values that can be tweaked to suit the implementation specifics.
response_type = code (tells that the exchange is based on an Authorization Code and not tokens) - This can be hardcoded in the Widget
client_id = FARMER_REGISTRY_DOA_SOME_PROVINCE
redirect_uri = https://farmer_registry.doasp.org/oidc/callback
scope = openid profile
openid (mandatory, confirms OpenID protocol)
profile (requests for basic ID profile)
The registry ideally should not request for any more claims
state = generated random value
the API generates a random value and stores it in memory
the IdP gets this state value in the request
the IdP does not change this value and returns this unchanged value back in the registry callback
the registry will validate this value on receiving the callback from IdP, during Step-8
this mechanism is to mitigate CSRF attacks
code_challenge
the API generates a random value (called code_verifier) and stores it in memory
code_challenge = BASE64(SHA256(code_verifier)
the IdP will use this code_challenge in Step-9 to validate whether the requester is the original owner of the transaction
This mechanism, called PKCE (Proof Key for Code Exchange), ensures that an authorization code can be redeemed only by the component that initiated the authorization transaction. Even if an authorization code is intercepted, it is unusable without the corresponding proof key (
code_verifier). PKCE provides a dynamic, per-transaction proof of possession of the authorisation transaction.
code_challenge_method
S256 - This says the code_challenge has been created using the SHA-256 algorithm
The IDP will use this algorithm to compute the Hash Value of the Code Verifier in Step-9
nonce
This is a random String (high entropy, high randomness) generated by this API
The API will store this NONCE
In Step-8, when the Registry receives the token (registry exchanges the authorization_code for tokens), the registry will unpack the NONCE and validate this NONCE value
This NONCE validation, ensures that a TOKEN is bound to the original STATE (mentioned in Point 5)
To support this functionality, the API - start_authentication_transaction will store the following Auth_Transaction object in REDIS. This object will be addressed (retrievable) by using the STATE value as Key.
Step-3 (302 Redirect from OIDC Widget to IdP Authorization Endpoint)
Step - 4 (Navigate to IdP Authorization endpoint)
This is handled by the Browser Engine
Step - 5 (Authenticate Registrant)
This is handled by the IdP depending on how the ID Authentication mechanism has been configured.
Step - 6 (Redirect to redirect_uri)
This is handled by the IdP, once it establishes the result of Authentication
Step - 7 (Handle the redirect into redirect_uri)
This is handled by the Browser Engine
Step - 8 (Exchange the Authorization_Code for Tokens)
This API is implemented by the Registry. This is the API that is specified in the original request as "redirect_uri" — https://farmer_registry.doasp.org/registrant_authentication/callback
In this API, the Registry will receive the "Authorization_Code" and the "State" as URL parameters
Retrieve the Auth_Transaction using the state
Validate existence of State
Validate expiry time of the Transaction
Use Code_Verifier and call the IdP to exchange the Authorization_Code for Token
This is a POST request (Server to Server)
Endpoint
HTTP Request
HTTP Request Body
Step - 9 (Return the Tokens)
The IdP validates the code_verifier (using SHA-256) and returns the Tokens.
Step - 10 (Validate ID Token and create "Identity-Verification" Context)
Validate the Signature of the Token
The Public Keys of the IdP are available at
Read
kidfrom ID token headerSelect matching key from JWKS
Verify the signature using the declared algorithm (
alg)
Validate the following claims
ClaimValidationissMust match IdP issuer
audMust contain registry client_id - FARMER_REGISTRY_DOA_SOME_PROVINCE
expMust be in the future
iatMust be reasonable
nbf(If present) must be ≤ now
nonceMust match stored nonce (auth_transaction.nonce)
subMust be present and the value should match the auth_transaction.registrant_id
Create an "Identity-Verification" context
The Register-Record should have a status = "Identity-verified" - BOOLEAN - that should be marked TRUE along with the latest "identity-verificationId"
The Identity-Verification Context should be persisted in another table - which has Identity-VerificationId as the Primary Key
Step - 11 (Return Success Response to Browser)
Last updated
Was this helpful?

