kayleecodes1 / cas-authentication

A CAS authentication library designed to be used as middleware for an Express server.
MIT License
73 stars 76 forks source link

Getting error Cannot read property 'authenticationfailure' of undefined #10

Open ghost opened 8 years ago

ghost commented 8 years ago

Hi,

After successfully login to cas and redirect back, getting below error again and again while accessing api.

[2] [TypeError: Cannot read property 'authenticationfailure' of undefined] [2] [Error: CAS authentication failed.] My service is pointing to localhost. Is there a way to debug ?

jonalbertini commented 7 years ago

Same problem :

TypeError: Cannot read property 'authenticationfailure' of undefined                                                                                   
    at /home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/cas-authentication/index.js:78:57                                                    
    at Parser.<anonymous> (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/xml2js/lib/xml2js.js:489:18)                                     
    at emitOne (events.js:96:13)                                                                                                                       
    at Parser.emit (events.js:188:7)                                                                                                                   
    at Object.onclosetag (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/xml2js/lib/xml2js.js:447:26)                                      
    at emit (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/sax/lib/sax.js:640:35)                                                         
    at emitNode (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/sax/lib/sax.js:645:5)                                                      
    at closeTag (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/sax/lib/sax.js:905:7)
    at Object.write (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/sax/lib/sax.js:1449:13)                                                
    at Parser.exports.Parser.Parser.parseString (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/xml2js/lib/xml2js.js:508:31)               
Error: CAS authentication failed.                                                                                                                      
    at /home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/cas-authentication/index.js:92:37                                                    
    at Parser.<anonymous> (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/xml2js/lib/xml2js.js:489:18)                                     
    at emitOne (events.js:96:13)                                                                                                                       
    at Parser.emit (events.js:188:7)                                                                                                                   
    at Object.onclosetag (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/xml2js/lib/xml2js.js:447:26)                                      
    at emit (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/sax/lib/sax.js:640:35)                                                         
    at emitNode (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/sax/lib/sax.js:645:5)                                                      
    at closeTag (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/sax/lib/sax.js:905:7)                                                      
    at Object.write (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/sax/lib/sax.js:1449:13)                                                
    at Parser.exports.Parser.Parser.parseString (/home/jonas/Documents/Node/MKBrowser/cas_test/node_modules/xml2js/lib/xml2js.js:508:31)

I've made a console log of the result object and I've got :

{"html":{"head":{"title":"404 Not Found"},"body":{"h1":"Not Found","p":"The requested URL //serviceValidate was not found on this server."}}}  

so, obviously no result.serviceresponse.authenticationfailure...

I suspect an parse error form index.js Line 67. but can't resolve it.

kayleecodes1 commented 7 years ago

I'm doing a rewrite of this module (with no API-breaking changes) and I'm going to validate the structure of the CAS server's response. All this will do it provide a more useful error message, though.

If the CAS server in the test cases was operating correctly and on the correct version, then this might be a problem with slashes. I'll be properly building and checking my request URLs in the new version.