{"action":"created","issue":{"url":"https://api.github.com/repos/molekilla/hapi-passport-saml/issues/5","repository_url":"https://api.github.com/repos/molekilla/hapi-passport-saml","labels_url":"https://api.github.com/repos/molekilla/hapi-passport-saml/issues/5/labels{/name}","comments_url":"https://api.github.com/repos/molekilla/hapi-passport-saml/issues/5/comments","events_url":"https://api.github.com/repos/molekilla/hapi-passport-saml/issues/5/events","html_url":"https://github.com/molekilla/hapi-passport-saml/issues/5","id":203927545,"number":5,"title":"Some issues using logout as-is in the example","user":{"login":"cbebry","id":3312895,"avatar_url":"https://avatars.githubusercontent.com/u/3312895?v=3","gravatar_id":"","url":"https://api.github.com/users/cbebry","html_url":"https://github.com/cbebry","followers_url":"https://api.github.com/users/cbebry/followers","following_url":"https://api.github.com/users/cbebry/following{/other_user}","gists_url":"https://api.github.com/users/cbebry/gists{/gist_id}","starred_url":"https://api.github.com/users/cbebry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbebry/subscriptions","organizations_url":"https://api.github.com/users/cbebry/orgs","repos_url":"https://api.github.com/users/cbebry/repos","events_url":"https://api.github.com/users/cbebry/events{/privacy}","received_events_url":"https://api.github.com/users/cbebry/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2017-01-30T04:53:34Z","updated_at":"2017-01-31T06:21:19Z","closed_at":null,"body":"I have some interest in using hapi for a saml service provider, so I set up the examples in this repository. I was able to get the login and assert functionalities working great against an IDP (simplesamlphp) but am having some trouble with the logout functionality. \r\n\r\nAm I supposed to add the user object to the request object through some means? I traced through the exception trace pasted below and found that ```req.user.nameIDFormat``` in the function ```SAML.prototype.generateLogoutRequest``` expects a ```user``` object in the request that is passed in.\r\nDo you have any thoughts on how this could be made to work? \r\n\r\nThank you for your time.\r\n\r\n```\r\nDebug: internal, implementation, error \r\n    TypeError: Uncaught error: Cannot read property 'nameIDFormat' of undefined\r\n    at SAML.generateLogoutRequest (/home/spectrum/hapi-passport-saml-example/node_modules/passport-saml/lib/passport-saml/saml.js:223:28)\r\n    at SAML.getLogoutUrl (/home/spectrum/hapi-passport-saml-example/node_modules/passport-saml/lib/passport-saml/saml.js:435:22)\r\n    at exports.logout (/home/spectrum/hapi-passport-saml-example/lib/v1.js:96:10)\r\n    at Object.internals.handler (/home/spectrum/hapi-passport-saml-example/node_modules/hapi/lib/handler.js:93:36)\r\n    at /home/spectrum/hapi-passport-saml-example/node_modules/hapi/lib/handler.js:28:23\r\n    at internals.Protect.run (/home/spectrum/hapi-passport-saml-example/node_modules/hapi/lib/protect.js:56:5)\r\n    at exports.execute (/home/spectrum/hapi-passport-saml-example/node_modules/hapi/lib/handler.js:22:22)\r\n    at /home/spectrum/hapi-passport-saml-example/node_modules/hapi/lib/request.js:376:13\r\n    at iterate (/home/spectrum/hapi-passport-saml-example/node_modules/hapi/node_modules/items/lib/index.js:35:13)\r\n    at done (/home/spectrum/hapi-passport-saml-example/node_modules/hapi/node_modules/items/lib/index.js:27:25)\r\n```\r\n\r\n\r\n\r\n\r\n\r\nExample reference::\r\n```\r\n/**\r\n * Logout\r\n * @function\r\n * @param {Object} request - A Hapi Request\r\n * @param {Object} reply - A Hapi Reply\r\n */\r\nexports.logout = function (request, reply) {\r\n    var options = {\r\n        name_id: request.server.app.name_id,\r\n        session_index: request.server.app.session_index\r\n    };\r\n\r\n    var saml = request.server.plugins['hapi-passport-saml'].instance;\r\n\r\n    saml.getLogoutUrl(request, function(err, url) {\r\n        if (err !== null)\r\n            return reply.code(500);\r\n        return reply.redirect(url);        \r\n    });\r\n};\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/molekilla/hapi-passport-saml/issues/comments/276284668","html_url":"https://github.com/molekilla/hapi-passport-saml/issues/5#issuecomment-276284668","issue_url":"https://api.github.com/repos/molekilla/hapi-passport-saml/issues/5","id":276284668,"user":{"login":"cbebry","id":3312895,"avatar_url":"https://avatars.githubusercontent.com/u/3312895?v=3","gravatar_id":"","url":"https://api.github.com/users/cbebry","html_url":"https://github.com/cbebry","followers_url":"https://api.github.com/users/cbebry/followers","following_url":"https://api.github.com/users/cbebry/following{/other_user}","gists_url":"https://api.github.com/users/cbebry/gists{/gist_id}","starred_url":"https://api.github.com/users/cbebry/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbebry/subscriptions","organizations_url":"https://api.github.com/users/cbebry/orgs","repos_url":"https://api.github.com/users/cbebry/repos","events_url":"https://api.github.com/users/cbebry/events{/privacy}","received_events_url":"https://api.github.com/users/cbebry/received_events","type":"User","site_admin":false},"created_at":"2017-01-31T06:21:19Z","updated_at":"2017-01-31T06:21:19Z","body":"If we follow the path of creating an auth scheme, how do we handle setting the credentials/artifacts objects outside of the authentication function? I attempted to set the artifacts values between routes and it does not appear that hapi is meant to be used that way.\r\n\r\nI looked into another auth scheme, ```hapi-auth-cookie```, which appears to use state in order to save values and provides a way of managing setting values on a session, which could be used to persist the values we would want to send as part of the logout request, and likely other interactions with the auth scheme. \r\nThat said, does it make sense to use ```hapi-auth-cookie``` for this, or is this overkill? I'd like to be able to contribute with the project so I don't mind spending some time putting together fleshed out examples, but I want to make sure I'm heading in the right direction.\r\n\r\nTo see if I could avoid going down this path, I attempted setting request.user to {nameIDFormat} but it complains about:\r\n\r\n``` Error: Uncaught error: Missing attribute value for attribute Format of element saml:NameID```\r\n\r\nI am planning on hardcoding the value of that attribute for now, but it seems like an auth scheme is the right direction to go, as those values initially provided by the IDP can be saved to be used in the logout request."}}
{"actor":{"display_login":"cbebry"}}