Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: NDI OIDC for Singpass and Corppass OIDC for Corppass authentication #473

Merged
merged 4 commits into from
Dec 29, 2022

Conversation

justynoh
Copy link
Contributor

@justynoh justynoh commented Dec 29, 2022

Problem

(See also #210)

Currently, Mockpass does not support NDI OIDC for Singpass and Corppass OIDC for Corppass authentication according to the latest API documentation. This PR implements this.

Solution

This PR includes the following:

  • NDI OIDC and Corppass OIDC under the /singpass/v2 and /corppass/v2 namespaces respectively. Since these occupy the /singpass and /corppass namespaces too, I also moved both files into a project folder /oidc to reflect their purpose. The differences between the "implicit v1" and the v2 endpoints are as follows:
    • A chunk of functionality was similar to Singpass OIDC. In particular, almost no change has been made to the authorize and authorize/custom-profile endpoints. All the helper functions for both v1 and v2 were shared, so I moved them into a utils.js file.
    • For the token endpoint, the RP is expected to expose a well-known endpoint for the RP enc and sig JWKS. This endpoint must be made known to NDI ahead of time. (These are included as environment variables as described below.)
    • Two additional endpoints are added, /.well-known/openid-configuration and /.well-known/keys, which are the OIDC discovery endpoint and ASP JWKS endpoint respectively.
  • Corppass OIDC requires use of EC keys, and while NDI OIDC still allows RSA keys, it is only for backward compatibility. For this reason and that the keys are now exposed in JWKS format, I added four new keysets to the static/certs/ folder.
    • oidc-v2-asp-public.json: The ASP public signing key (exposed under /.well-known/keys).
    • oidc-v2-asp-secret.json: The ASP private signing key (used to sign the id token).
    • oidc-v2-rp-public.json and oidc-v2-rp-secret.json: Default RP signing and encryption keys. See below for more details.
  • Readme has also been updated.

More details about oidc-v2-rp-*.json:
Signing keys are used to sign the client assertion, and encryption keys are used to encrypt the id token). The entire protocol will still work if RPs do not use these keysets (which is correct behavior). Users may now either

  • not provide the {S|C}P_RP_JWKS_ENDPOINT environment variable, and use oidc-v2-rp-secret.json to sign their client assertion, the /token endpoint will default to verifying the client assertion with oidc-v2-rp-public.json, OR
  • provide the {S|C}P_RP_JWKS_ENDPOINT environment variable, and use their own keys to sign the client assertion, the /token endpoint will fetch their JWKS from the endpoint specified in the environment variable for use in verification.

Tests

FormSG's current RP implementation integrates correctly with Singpass and Corppass in both staging and prod. This branch has been tested with FormSG's implementation and works correctly in dev as well.

Deploy Notes

New environment variables:

  • SP_RP_JWKS_ENDPOINT : The RP's well-known JWKS endpoint for Singpass signing and encryption keys.
  • CP_RP_JWKS_ENDPOINT: The RP's well-known JWKS endpoint for Corppass signing and encryption keys.

New keys: (see above for more details)

  • oidc-v2-asp-public.json: The ASP public signing key.
  • oidc-v2-asp-secret.json: The ASP private signing key.
  • oidc-v2-rp-public.json and oidc-v2-rp-secret.json: Default RP signing and encryption keys.

@justynoh justynoh changed the title feat: implement NDI OIDC for Singpass and Corppass OIDC for Corppass authentication feat: NDI OIDC for Singpass and Corppass OIDC for Corppass authentication Dec 29, 2022
Copy link
Collaborator

@LoneRifle LoneRifle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@LoneRifle LoneRifle merged commit 8d3588a into opengovsg:master Dec 29, 2022
@justynoh justynoh deleted the feat/ndi-oidc branch December 29, 2022 03:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants