MCPcopy Index your code
hub / github.com/nodeSolidServer/node-solid-server / handler

Function handler

lib/api/authn/webid-tls.mjs:9–36  ·  view source on GitHub ↗
(req, res, next)

Source from the content-addressed store, hash-verified

7}
8
9export function handler (req, res, next) {
10 // User already logged in? skip
11 if (req.session.userId) {
12 debugAuth('User: ' + req.session.userId)
13 res.set('User', req.session.userId)
14 return next()
15 }
16
17 // No certificate? skip
18 const certificate = getCertificateViaTLS(req)
19 if (!certificate) {
20 setEmptySession(req)
21 return next()
22 }
23
24 // Verify webid
25 webid.verify(certificate, function (err, result) {
26 if (err) {
27 debugAuth('Error processing certificate: ' + err.message)
28 setEmptySession(req)
29 return next()
30 }
31 req.session.userId = result
32 debugAuth('Identified user: ' + req.session.userId)
33 res.set('User', req.session.userId)
34 return next()
35 })
36}
37
38// Tries to obtain a client certificate retrieved through the TLS handshake
39function getCertificateViaTLS (req) {

Callers

nothing calls this directly

Calls 3

getCertificateViaTLSFunction · 0.85
setEmptySessionFunction · 0.85
verifyMethod · 0.80

Tested by

no test coverage detected