-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathprotocolSaml.js
32 lines (28 loc) · 1.35 KB
/
protocolSaml.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
'use strict'
const Promise = require('bluebird')
const moment = require('moment')
const p23Validate = require('./protocol23.js')
const xml = require('./xml')
const debug = require('debug')('loopback:component:cas')
/* samlValidate */
module.exports = function (app, config, req, res, next, loginCallback) {
let MajorVersion = req.body['SOAP-ENV:Envelope']['SOAP-ENV:Body']['samlp:Request']['$']['MajorVersion']
//let MinorVersion = req.body['SOAP-ENV:Envelope']['SOAP-ENV:Body']['samlp:Request']['$']['MinorVersion']
// RequestID like '_192.168.16.51.1024506224022'
let RequestID = req.body['SOAP-ENV:Envelope']['SOAP-ENV:Body']['samlp:Request']['$']['RequestID']
// IssueInstant like '2002-06-19T17:03:44.022Z'
let IssueInstant = req.body['SOAP-ENV:Envelope']['SOAP-ENV:Body']['samlp:Request']['$']['IssueInstant']
/* SAML 1.0 or 1.1 for now */
if (MajorVersion == 1) {
// The TARGET variable will be the indication of the SAML protcol
req.query['service'] = req.query['TARGET']
req.query['ticket'] = req.body['SOAP-ENV:Envelope']['SOAP-ENV:Body']['samlp:Request']['samlp:AssertionArtifact']
p23Validate(app, config, req, res, next, loginCallback, true)
} else {
debug('TODO:samlValidate:protocol>1.1')
return res.send(xml.invalidSTSaml.renderToString({
issueinstant: moment().toISOString(),
audience: service.url
}))
}
}