@opengovsg/mockpass 3.1.3 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +5 -3
- package/lib/express/sgid.js +43 -38
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -44,9 +44,11 @@ MyInfo:
|
|
|
44
44
|
- http://localhost:5156/myinfo/v3/person
|
|
45
45
|
|
|
46
46
|
sgID:
|
|
47
|
-
- http://localhost:5156/
|
|
48
|
-
- http://localhost:5156/
|
|
49
|
-
- http://localhost:5156/
|
|
47
|
+
- http://localhost:5156/v2/oauth/authorize
|
|
48
|
+
- http://localhost:5156/v2/oauth/token
|
|
49
|
+
- http://localhost:5156/v2/oauth/userinfo
|
|
50
|
+
- http://localhost:5156/v2/.well-known/openid-configuration - OpenID discovery endpoint
|
|
51
|
+
- http://localhost:5156/v2/.well-known/jwks.json - JWKS endpoint which exposes the auth provider's signing keys
|
|
50
52
|
|
|
51
53
|
Provide your application with the `spcp*` certs found in `static/certs`
|
|
52
54
|
and with application certs at `static/certs/{key.pem|server.crt}`
|
package/lib/express/sgid.js
CHANGED
|
@@ -12,7 +12,9 @@ const LOGIN_TEMPLATE = fs.readFileSync(
|
|
|
12
12
|
'utf8',
|
|
13
13
|
)
|
|
14
14
|
|
|
15
|
-
const
|
|
15
|
+
const VERSION_PREFIX = '/v2'
|
|
16
|
+
const OAUTH_PREFIX = '/oauth'
|
|
17
|
+
const PATH_PREFIX = VERSION_PREFIX + OAUTH_PREFIX
|
|
16
18
|
|
|
17
19
|
const signingPem = fs.readFileSync(
|
|
18
20
|
path.resolve(__dirname, '../../static/certs/spcp-key.pem'),
|
|
@@ -77,7 +79,7 @@ function config(app, { showLoginPage, serviceProvider }) {
|
|
|
77
79
|
`Profile ${JSON.stringify(profile)} with token scope ${scopes}`,
|
|
78
80
|
)
|
|
79
81
|
const accessToken = authCode
|
|
80
|
-
const iss = `${req.protocol}://${req.get('host')}`
|
|
82
|
+
const iss = `${req.protocol}://${req.get('host') + VERSION_PREFIX}`
|
|
81
83
|
|
|
82
84
|
const { idTokenClaims, refreshToken } = assertions.oidc.create.singPass(
|
|
83
85
|
profile,
|
|
@@ -165,49 +167,52 @@ function config(app, { showLoginPage, serviceProvider }) {
|
|
|
165
167
|
})
|
|
166
168
|
})
|
|
167
169
|
|
|
168
|
-
app.get(
|
|
170
|
+
app.get(`${VERSION_PREFIX}/.well-known/jwks.json`, async (_req, res) => {
|
|
169
171
|
const key = await jose.JWK.asKey(signingPem, 'pem')
|
|
170
172
|
const jwk = key.toJSON()
|
|
171
173
|
jwk.use = 'sig'
|
|
172
174
|
res.json({ keys: [jwk] })
|
|
173
175
|
})
|
|
174
176
|
|
|
175
|
-
app.get(
|
|
176
|
-
|
|
177
|
+
app.get(
|
|
178
|
+
`${VERSION_PREFIX}/.well-known/openid-configuration`,
|
|
179
|
+
async (req, res) => {
|
|
180
|
+
const issuer = `${req.protocol}://${req.get('host') + VERSION_PREFIX}`
|
|
177
181
|
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
182
|
+
res.json({
|
|
183
|
+
issuer,
|
|
184
|
+
authorization_endpoint: `${issuer}/${OAUTH_PREFIX}/authorize`,
|
|
185
|
+
token_endpoint: `${issuer}/${OAUTH_PREFIX}/token`,
|
|
186
|
+
userinfo_endpoint: `${issuer}/${OAUTH_PREFIX}/userinfo`,
|
|
187
|
+
jwks_uri: `${issuer}/.well-known/jwks.json`,
|
|
188
|
+
response_types_supported: ['code'],
|
|
189
|
+
grant_types_supported: ['authorization_code'],
|
|
190
|
+
// Note: some of these scopes are not yet officially documented
|
|
191
|
+
// in https://docs.id.gov.sg/data-catalog
|
|
192
|
+
// So they are not officially supported yet.
|
|
193
|
+
scopes_supported: [
|
|
194
|
+
'openid',
|
|
195
|
+
'myinfo.nric_number',
|
|
196
|
+
'myinfo.name',
|
|
197
|
+
'myinfo.email',
|
|
198
|
+
'myinfo.sex',
|
|
199
|
+
'myinfo.race',
|
|
200
|
+
'myinfo.mobile_number',
|
|
201
|
+
'myinfo.registered_address',
|
|
202
|
+
'myinfo.date_of_birth',
|
|
203
|
+
'myinfo.passport_number',
|
|
204
|
+
'myinfo.passport_expiry_date',
|
|
205
|
+
'myinfo.nationality',
|
|
206
|
+
'myinfo.residentialstatus',
|
|
207
|
+
'myinfo.residential',
|
|
208
|
+
'myinfo.housingtype',
|
|
209
|
+
'myinfo.hdbtype',
|
|
210
|
+
],
|
|
211
|
+
id_token_signing_alg_values_supported: ['RS256'],
|
|
212
|
+
subject_types_supported: ['pairwise'],
|
|
213
|
+
})
|
|
214
|
+
},
|
|
215
|
+
)
|
|
211
216
|
}
|
|
212
217
|
|
|
213
218
|
const concatMyInfoRegAddr = (regadd) => {
|