8 Service APIs

This section provides a reference for APIs that should be implemented by this Building Block.

The APIs defined here establish a blueprint for how the Building Block will interact with other Building Blocks. Additional APIs may be implemented by the Building Block, but the listed APIs define a minimal set of functionality that should be provided by any implementation of this Building Block.

In common for all services of the Identity Building Block, the API expects the calling Partner has been already authenticated and authorized to access the service. For detailed specifications of APIs with input/output formats please refer to API specifications defined in YAML in the corresponding GitHub repository.

The GovStack non-functional requirements document provides additional information on how 'adaptors' may be used to translate an existing API to the patterns described here. This section also provides guidance on how candidate products are tested and how GovStack validates a product's API against the API specifications defined here.

The tests for the Identity Building Block can be found in this GitHub repository.

API standards

8.1 Identity Usage

The Identity usage APIs are a set of OpenAPI specifications exposed by the Identity Building Block to other building blocks and applications for user verification.

The Identity usage APIs are based on the following principles:

  • Verification APIs are inspired from OpenID Connect protocol which simplifies integrations using pre-existing libraries

  • Only secure options in OpenID connect should be supported to ensure the user data is handled securely

  • All biometric capture for user verification should be done using Secure Biometrics Interface standards

Service Group: Client Management

Create OIDC Client Endpoint

post

API to add new open ID connect (OIDC) clients, it can be invoked by other modules which manages the relying parties / partners.

Each relying party can associate to one or multiple OIDC client Ids.

On create, OIDC client status will be by default set to "active".

Authorizations
Body

OIDC client details

requestTimestringrequired

Current date and time when the request is sent

requestobjectrequired

Responses
post
curl -L \
  --request POST \
  --url '/client-mgmt/oidc-client' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "2011-10-05T14:48:00.000Z",
    "request": {
      "clientId": "e-health-service",
      "clientName": "Health Service",
      "relyingPartyId": "bharath-gov",
      "logoUri": "http://example.com",
      "redirectUris": [
        "http://example.com/login-success"
      ],
      "publicKey": {},
      "authContextRefs": [
        "idbb:acr:generated-code"
      ],
      "userClaims": [
        "name"
      ],
      "grantTypes": [
        "authorization_code"
      ],
      "clientAuthMethods": [
        "private_key_jwt"
      ]
    }
  }'
{
  "responseTime": "text",
  "response": {
    "clientId": "text"
  },
  "errors": [
    {
      "errorCode": "duplicate_client_id",
      "errorMessage": "text"
    }
  ]
}

Update OIDC Client Endpoint

put

API to update existing Open ID Connect (OIDC) client, it can be invoked by other modules which manages the relying parties / partners when there any updates on the fields accepted in this API.

Authentication and authorization is based on a valid JWT issued by a trusted IAM system including "update_oidc_client" scope.

Authorizations
Path parameters
client_idstringrequired

Client Identifier

Example: 785b806d0e594657b05aabdb30fff8a4
Body
requestTimestringrequired

Current date and time when the request is sent

requestobjectrequired

Responses
put
curl -L \
  --request PUT \
  --url '/client-mgmt/oidc-client/{client_id}' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "2022-09-22T08:03:45.000Z",
    "request": {
      "clientName": "Health Service",
      "status": "active",
      "logoUri": "http://example.com",
      "redirectUris": [
        "http://example.com/login-success"
      ],
      "userClaims": [
        "name"
      ],
      "authContextRefs": [
        "idbb:acr:generated-code"
      ],
      "grantTypes": [
        "authorization_code"
      ],
      "clientAuthMethods": [
        "private_key_jwt"
      ]
    }
  }'
{
  "responseTime": "text",
  "response": {
    "clientId": "text"
  },
  "errors": [
    {
      "errorCode": "invalid_client_id",
      "errorMessage": "text"
    }
  ]
}

Authorization Endpoint

get

This is the authorize endpoint of Open ID Connect (OIDC). The relying party applications will do a browser redirect to this endpoint with all required details passed as query parameters.

This endpoint will respond with a HTML page / JS application to be loaded in the browser.

All the validations on the query parameter values will be performed, in case of any failures respective error message will be sent along with browser redirection back to relying party application.

Query parameters
scopestring · enumrequired

Specifies what access privileges are being requested for Access Tokens. The scopes associated with Access Tokens determine what resources will be available when they are used to access OAuth 2.0 protected endpoints. OpenID Connect requests MUST contain the OpenID scope value.

Default: openid profileAvailable options:
response_typestring · enumrequired

The value set here determines the authorization processing flow. To use the Authorization Code Flow, the value should be configured to "code".

Available options:
client_idstring · max: 256required

Valid OAuth 2.0 Client Identifier in the Authorization Server.

redirect_uristring · urirequired

Redirection URI to which the response would be sent. This URI must match one of the redirection URI values during the client ID creation.

statestring · max: 256optional

Opaque value used to maintain state between the request and the callback. Typically, Cross-Site Request Forgery (CSRF, XSRF) mitigation is done by cryptographically binding the value of this parameter with a browser cookie.

noncestringoptional

String value used to associate a Client session with an ID Token, and to mitigate replay attacks. The value is passed through unmodified from the Authentication Request to the ID Token.

displaystring · enumoptional

ASCII string value that specifies how the Authorization Server displays the authentication and consent user interface pages to the end user.

Available options:
promptstring · enumoptional

Space delimited case-sensitive list of ASCII string values that specifies whether the Authorization Server prompts the End-User for re-authentication and consent.

Example: consentAvailable options:
max_agenumberoptional

Maximum Authentication Age. This specifies the allowable elapsed time in seconds since the last time the end user was actively authenticated by the OP. If the elapsed time is greater than this value, then the OP MUST attempt to actively re-authenticate the end user. The max_age request parameter corresponds to the OpenID 2.0 PAPE [OpenID.PAPE] max_auth_age request parameter. When max_age is used, the ID Token returned MUST include an auth_time claim value.

ui_localesstringoptional

End user's preferred languages and scripts for the user interface, represented as a space-separated list of BCP47 [RFC5646] language tag values, ordered by preference. For instance, the value "fr-CA fr en" represents a preference for French as spoken in Canada, then French (without a region designation), followed by English (without a region designation). An error SHOULD NOT result if some or all of the requested locales are not supported by the OpenID Provider.

acr_valuesstring · enumoptional

Requested Authentication Context Class Reference values. Space-separated string that specifies the acr values that the Authorization Server is being requested to use for processing this Authentication Request, with the values appearing in order of preference. The Authentication Context Class satisfied by the authentication performed is returned as the acr Claim Value, as specified in Section 2. The acr Claim is requested as a Voluntary Claim by this parameter.

Available options:
claims_localesstringoptional

End-User's preferred languages and scripts for Claims being returned, represented as a space-separated list of BCP47 [RFC5646] language tag values, ordered by preference. An error SHOULD NOT result if some or all of the requested locales are not supported by the OpenID Provider.

claimsstringoptional

This parameter is used to request specific claims to be returned. The value is a JSON object listing the requested claims. The claims parameter value is represented in an OAuth 2.0 request as UTF-8 encoded JSON.

Responses
get
curl -L \
  --url '/authorize?scope=openid+profile&response_type=code&client_id=text&redirect_uri=https%3A%2F%2Fexample.com'

No Content

Token Endpoint

post

Once the client / relying party application receives the authorization code through redirect, this OIDC complaint endpoint will be called from the relying party backend application to get the ID Token and Access Token.

  1. The only supported client authentication method : private_key_jwt
  2. ClientAssertion is a signed JWT with client's private key, corresponding public key should be shared with IDBB during the OIDC client creation process.
  3. clientAssertion JWT payload must be as below:

The JWT MUST contain the following REQUIRED Claim Values and MAY contain few additional OPTIONAL Claim Values:

iss* (Issuer): This MUST contain the client_id of the OIDC / OAuth Client.

sub* (Subject): This MUST contain the client_id of the OIDC / OAuth Client.

aud* (Audience): Value that identifies the IDBB server as an intended audience. The IDBB server MUST verify that it is an intended audience for the token. The audience SHOULD be the URL of the IDBB's token endpoint.

exp* (Expiration): Time on or after which the ID token MUST NOT be accepted for processing.

iat*: Time at which the JWT was issued.

Note: The Client Assertion JWT can contain other Claims. Any Claims used that are not understood WILL be ignored.

Body
grant_typestring · enumrequired

Authorization code grant type.

Available options:
codestringrequired

Authorization code, sent as query param in the client's redirect URI.

client_idstringrequired

Client Id of the OIDC client.

client_assertion_typestring · enumrequired

Type of the client assertion part of this request.

Available options:
client_assertionstringrequired

Private key signed JWT, This JWT payload structure is defined above as part of request description.

redirect_uristringrequired

Valid client redirect_uri. Must be same as the one sent in the authorize call.

Responses
post
curl -L \
  --request POST \
  --url '/oauth/token' \
  --header 'Content-Type: application/x-www-form-urlencoded' \
  --data 'grant_type=authorization_code&code=text&client_id=text&client_assertion_type=urn:ietf:params:oauth:client-assertion-type:jwt-bearer&client_assertion=text&redirect_uri=text'
{
  "id_token": "text",
  "access_token": "text",
  "token_type": "Bearer",
  "expires_in": 1
}

UserInfo Endpoint

get

Once the access token is received via the token endpoint, relying party backend application can call this OIDC compliant endpoint to request for the user claims.

Consented user claims will be returned as a JWT. This JWT will be a nested JWT which is signed using JWS and then encrypted using JWE.

Example: Assuming the below are the requested claims by the relying party

name : { "essential" : true }

phone: { "essential" : true }

Response 1: When consent is provided for both name and phone number:

{ "name" : "John Doe", "phone" : "033456743" }

Response 2: When consent is provided for only name:

{ "name" : "John Doe" }

Response 3: When Claims are requested with claims_locales : "en fr"

{ "name#en" : "John Doe", "name#fr" : "Jean Doe", "phone" : "033456743" }

Supported User Info Claims

Authorizations
Responses
get
curl -L \
  --url '/oidc/userinfo' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN'
text

JSON Web Key Set Endpoint

get

Endpoint to fetch all the public keys of the IDBB server. Returns public key set in the JWKS format.

Responses
get
curl -L \
  --url '/.well-known/jwks.json'
{
  "keys": [
    {
      "kid": "text",
      "use": "sig",
      "kty": "RSA",
      "e": "text",
      "n": "text",
      "x5t#S256": "text",
      "x5c": [
        "text"
      ],
      "exp": "2026-02-05T13:43:07.979Z"
    }
  ]
}

Configuration Endpoint

get

This endpoint is only for facilitating the OIDC provider details in a standard way.

Reference: https://openid.net/specs/openid-connect-discovery-1_0.html

Responses
get
curl -L \
  --url '/.well-known/openid-configuration'
{
  "issuer": "text",
  "authorization_endpoint": "text",
  "token_endpoint": "text",
  "userinfo_endpoint": "text",
  "jwks_uri": "text",
  "registration_endpoint": "text",
  "scopes_supported": [
    "openid"
  ],
  "response_types_supported": [
    "code"
  ],
  "acr_values_supported": [],
  "userinfo_signing_alg_values_supported": [],
  "userinfo_encryption_alg_values_supported": [],
  "userinfo_encryption_enc_values_supported": [],
  "token_endpoint_auth_methods_supported": [
    "private_key_jwt"
  ],
  "display_values_supported": [],
  "claim_types_supported": [
    "normal"
  ],
  "claims_supported": [
    "text"
  ],
  "claims_locales_supported": [
    "text"
  ],
  "ui_locales_supported": [
    "text"
  ],
  "response_modes_supported": [
    "query"
  ],
  "token_endpoint_auth_signing_alg_values_supported": [
    "RS256"
  ],
  "id_token_signing_alg_values_supported": [
    "RS256"
  ]
}

For Identity Building Block implementations that support mobile wallet integration, the following API spec should also be implemented.

post

Generate link code request is raised from IDBB UI application.

  1. UI application creates a deeplink with this link-code as parameter.
  2. This deeplink is embedded in a Machine-readable-code (like QR code) and the same is rendered in the UI.
  3. End user scans this machine-readable-code to open wallet app.
  4. On open of wallet-app, wallet-app invokes /link-transaction endpoint.
  5. In the UI application, once machine-readable-code is rendered, at the same time /link-status endpoint is invoked as a long polling request.
Header parameters
X-XSRF-TOKENstringrequired

CSRF token as set in cookie key 'XSRF-TOKEN'

Body
requestTimestringrequired
requestobjectrequired

Responses
post
curl -L \
  --request POST \
  --url '/linked-authorization/link-code' \
  --header 'X-XSRF-TOKEN: text' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "text",
    "request": {
      "transactionId": "text"
    }
  }'
{
  "responseTime": "text",
  "response": {
    "transactionId": "text",
    "linkCode": "text",
    "expireDateTime": "text"
  },
  "errors": [
    {
      "errorCode": "invalid_transaction_id",
      "errorMessage": "text"
    }
  ]
}
post

The link status endpoint is invoked from IDBB UI application.

  1. Checks the status of link code and will return the status as LINKED once the /link-transaction endpoint is called from wallet application.
Header parameters
X-XSRF-TOKENstringrequired

CSRF token as set in cookie key 'XSRF-TOKEN'

Body
requestTimestringrequired
requestobjectrequired

Responses
post
curl -L \
  --request POST \
  --url '/linked-authorization/link-status' \
  --header 'X-XSRF-TOKEN: text' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "text",
    "request": {
      "transactionId": "text",
      "linkCode": "text"
    }
  }'
{
  "responseTIme": "text",
  "response": {
    "transactionId": "text",
    "linkStatus": "LINKED",
    "linkedDateTime": "text"
  },
  "errors": [
    {
      "errorCode": "invalid_transaction_id",
      "errorMessage": "text"
    }
  ]
}
post

Link authorization code endpoint is invoked from UI application.

  1. This is a Long polling request to IDBB backend.
  2. validates the transactionId
  3. validates the linkCode if its LINKED.
  4. checks the cache to see if the auth-code is generated, if yes returns the response.
  5. If the auth-code is not yet generated, polling request waits for the configured time.
  6. On successful response, IDBB UI should redirect to the provided redirectUri with auth-code or error details.
Header parameters
X-XSRF-TOKENstringrequired

CSRF token as set in cookie key 'XSRF-TOKEN'

Body
requestTimestringrequired
requestobjectrequired

Responses
post
curl -L \
  --request POST \
  --url '/linked-authorization/link-auth-code' \
  --header 'X-XSRF-TOKEN: text' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "text",
    "request": {
      "transactionId": "text",
      "linkedCode": "text"
    }
  }'
{
  "responseTime": "text",
  "response": {
    "code": "text",
    "redirectUri": "text",
    "state": "text",
    "nonce": "text"
  },
  "errors": [
    {
      "errorCode": "invalid_transaction",
      "errorMessage": "text"
    }
  ]
}
post

The link transaction endpoint is invoked from Wallet-app.

  1. Validates the link-code and its expiry and generates the linkTransactionId. This linkTransactionId is linked to transactionId used in the /link-code endpoint.

  2. Returns the auth-factors, clientName, logoUrl, User claims, authorize scopes along with linkTransactionId.

Note: Wallet-app will hereafter address the transaction with this linkTransactionId for the /authenticate and /consent endpoints.

Body
requestTimestringrequired
requestobjectrequired

Responses
post
curl -L \
  --request POST \
  --url '/linked-authorization/link-transaction' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "text",
    "request": {
      "linkCode": "text"
    }
  }'
{
  "responseTime": "text",
  "response": {
    "linkTransactionId": "text",
    "clientName": "text",
    "logoUrl": "text",
    "authorizeScopes": [
      "text"
    ],
    "essentialClaims": [
      "text"
    ],
    "voluntaryClaims": [
      "text"
    ],
    "authFactors": [
      [
        {
          "type": "PIN",
          "count": 1,
          "bioSubTypes": [
            "text"
          ]
        }
      ]
    ],
    "configs": {}
  },
  "errors": [
    {
      "errorCode": "invalid_link_code",
      "errorMessage": "text"
    }
  ]
}

Linked Authentication Endpoint

post

Once end user provides the user identifier (UIN/VID) and all the required auth challenge to the Wallet-app, this endpoint will be invoked from wallet-app.

Supported auth-challenge depends on the integrated IDBB implementation.

  1. Validates linkedTransactionId.
  2. Validates null / empty individualId.

On Authentication Success: Only linkTransactionId is returned in the below response without any errors.

On Authentication Failure: Error list will be returned.

Body
requestTimestringrequiredPattern: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
requestobjectrequired

Responses
post
curl -L \
  --request POST \
  --url '/linked-authorization/authenticate' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "text",
    "request": {
      "linkedTransactionId": "text",
      "individualId": "text",
      "challengeList": [
        {
          "authFactorType": "OTP",
          "challenge": "text",
          "format": "alpha-numeric"
        }
      ]
    }
  }'
{
  "responseTime": "text",
  "response": {
    "linkedTransactionId": "text"
  },
  "errors": [
    {
      "errorCode": "invalid_transaction_id",
      "errorMessage": "text"
    }
  ]
}
post

Once the authentication is successful and user permission is obtained, this endpoint will be invoked by the wallet app to send the accepted user claims and permitted scopes.

  1. Validates linkedTransactionId.
  2. Validate accepted claims and permitted scopes in the request.
  3. If valid, stores the accepted claims and permitted scopes in the datastore.
Body
requestTimestringrequiredPattern: yyyy-MM-dd'T'HH:mm:ss.SSS'Z'
requestobjectrequired

Responses
post
curl -L \
  --request POST \
  --url '/linked-authorization/consent' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "text",
    "request": {
      "linkedTransactionId": "text",
      "permittedAuthorizeScopes": [
        "text"
      ],
      "acceptedClaims": [
        "text"
      ]
    }
  }'
{
  "responseTime": "text",
  "response": {
    "linkedTransactionId": "text"
  },
  "errors": [
    {
      "errorCode": "invalid_transaction_id",
      "errorMessage": "text"
    }
  ]
}

Wallet Binding Endpoint (Draft)

post

Wallet binding endpoint is invoked by Wallet's backend server.

  1. Action will be initiated from wallet-app with authChallenge by user.
  2. Wallet backend server will receive the authChallenge, create this request and send to IDBB to complete the binding process.
  3. Binded walletUserId (WUID) is returned with IDBB signed certificate.

Note: Binding entry uniqueness is combination of these 3 values -> (PSUT, public-key, auth-factor-type)

Authorizations
Header parameters
PARTNER-IDstringrequired

An identifier for the partner.

PARTNER-API-KEYstringrequired

An API key provided to the partner for authentication purposes.

Body
requestTimestringrequired
requestobjectrequired

Responses
post
curl -L \
  --request POST \
  --url '/wallet-binding' \
  --header 'Authorization: Bearer YOUR_SECRET_TOKEN' \
  --header 'PARTNER-ID: text' \
  --header 'PARTNER-API-KEY: text' \
  --header 'Content-Type: application/json' \
  --data '{
    "requestTime": "text",
    "request": {
      "individualId": "text",
      "authFactorType": "text",
      "format": "text",
      "challengeList": [
        {
          "authFactorType": "OTP",
          "challenge": "text",
          "format": "alpha-numeric"
        }
      ],
      "publicKey": {}
    }
  }'
{
  "responseTime": "text",
  "response": {
    "walletUserId": "text",
    "certificate": "text",
    "expireDateTime": "text"
  },
  "errors": [
    {
      "errorCode": "unsupported_challenge_format",
      "errorMessage": "text"
    }
  ]
}

Detailed API schemas written in YAML that define REST API endpoints for each of the services mentioned above are available on GitHub located at the Identity-Provider YAML.

The GovStack non-functional requirements document provides additional information on how 'adaptors' may be used to translate an existing API to the patterns described here.

8.2 Identity Management

The Enrollment APIs are a set of OpenAPI specifications exposed by the Identity Building Block ‘Enrollment Server’ service to any enrollment client.

The Enrollment APIs are based on the following principles:

  • When enrollment is done in one step, the CreateEnrollment can contain all the data and an additional flag (finalize) to indicate all data was collected.

  • During the process, the enrollment structure can be updated. Only the data that changed need to be transferred. Data not included is left unchanged on the server. In the following example, the biographic data is not changed.

  • Images can be passed by value or reference.

  • Existing standards are used whenever possible, for instance, the preferred image format for biometric data is ISO-19794. The underlying data should be of open mime types that offer good compression without loss of data (for example JPEG2000 for images).

8.3 Credential Management

This Services APIs is not yet specified, but it should be the purpose of a next iteration of the Identity Building Block Specification.

8.4 Subscription Management

This Services APIs is not yet specified, but it should be the purpose of a next iteration of the Identity Building Block Specification.

8.5 Administration Management

This Services APIs is not yet specified, but it should be the purpose of a next iteration of the Identity Building Block Specification.

Last updated

Was this helpful?