Add support for FAPI for Singpass Login#800
Conversation
There was a problem hiding this comment.
nit - there should be naming consistency - if you have a fapi.service.js, you should have a fapi.controller.js too
| const { readFileSync } = require('fs') | ||
| const path = require('path') | ||
|
|
||
| const issuer = 'http://localhost:5156/v3/fapi' |
There was a problem hiding this comment.
MockPass auth endpoints would typically construct the issuer in a manner that trusts the requests, to ensure that developers can reconfigure mockpass as they wish without worrying
You may wish to look at the other endpoint implementations to see how this might be done.
| } | ||
|
|
||
| const FAPI_PATH = '/v3/fapi' | ||
| let issuer = `http://localhost:5156${FAPI_PATH}` //default issuer |
There was a problem hiding this comment.
As discussed in the prior review. Please refactor as needed
There was a problem hiding this comment.
This is the default value if running locally.
I added a getFapiOpenIdConfiguration(req) that will be called by the service layer. This will determine the protocol and host and update the FapiConfiguration using the values in req during runtime.
e.g.
app.get(
`${FapiUtils.FAPI_PATH}/.well-known/openid-configuration`,
(req, res) => {
return res.send(FapiUtils.getFapiOpenIdConfiguration(req))
},
)
When called, it will ensure that the endpoints are tagged to the developer's host
function getIssuerFromRequest(req) {
return `${req.protocol}://${req.get('host')}${FAPI_PATH}`
}
function getFapiOpenIdConfiguration(req) {
const issuer = getIssuerFromRequest(req)
return {
...fapiOidcConfiguration,
issuer,
jwks_uri: `${issuer}/.well-known/keys`,
pushed_authorization_request_endpoint: `${issuer}/par`,
authorization_endpoint: `${issuer}/auth`,
token_endpoint: `${issuer}/token`,
}
}
There was a problem hiding this comment.
Would it then be better to not actually have the default value at all, given that this would change at runtime? Having the hard-coded value and then discarding it at runtime strikes me as a code smell, and may catch out people who are relatively new to the codebase.
There was a problem hiding this comment.
Good point, I have removed the issuer from the code and refactored it. Thanks!
Problem
Add support for FAPI flow
Closes #799
Solution
The existing v2-OIDC flow for Singpass Login is deprecated and new RPs are advised to use the FAPI flow for integration with Singpass Login.
Features:
/v3/fapi/parendpoint to create a sign request./v3/fapi/authwill no longer take in the parameters that are currently present in the OIDC flow.v3/fapi/tokenwill require a DPoP tokenImproved Security
Configuration
process.env.FAPI_CLIENT_JWKS_ENDPOINT- for configuring the JWKS endpointAllowed Scopes
Currently, only the following are supported
openiduinfinuser.identityTests
As tests are not a norm in this repository, I tested manually with my test application.
A test endpoint is created for simulating the FAPI flow without a server setup.
Limitations
openidanduser.identityclient_id:<state>as the client_id