Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Access attributes from IdP? #188

Closed
jakobsen9 opened this issue Feb 2, 2017 · 4 comments
Closed

Access attributes from IdP? #188

jakobsen9 opened this issue Feb 2, 2017 · 4 comments

Comments

@jakobsen9
Copy link

Hi all,

I am using Angular 2, and would like to take usage of the attributes the IdP provides in the SAML response. Where are those attributes stored, and how can I call them in for ex. a html file? Are they stored in any global variables?

@jakobsen9 jakobsen9 changed the title Use attributes from IdP Access attributes from IdP? Feb 2, 2017
@jakobsen9
Copy link
Author

jakobsen9 commented Feb 2, 2017

I have tried the implementation presented in #165, but I get the error Error: passport.initialize() middleware not in use. I have found out that the error occours when the 2nd return argument is set in this:

var strategy = new SamlStrategy(
{
callbackUrl: 'http://localhost:3000/login/callback',
entryPoint: 'https://idp-test.feide.no/simplesaml/saml2/idp/SSOService.php',
issuer: 'http://localhost:3000/feide/metadata',
logoutUrl: 'https://idp-test.feide.no/simplesaml/saml2/idp/SingleLogoutService.php',
logoutCallbackUrl: 'http://localhost:3000/logout'
},
function(profile, done) {
return done(null,
{
id: profile.uid,
email: profile.mail
});
})

Earlier I had only the first return argument, return done(null), and that worked.

@jakobsen9
Copy link
Author

Found out that I missed the following in the same file as above:

passport.serializeUser(function (user, done) {
done(null, user);
});

passport.deserializeUser(function (user, done) {
done(null, user);
});

router.use(passport.initialize());

Now it's working without errors, and I have printed to see that the attributes are saved in user.

But I still don't figure out how to call the arguments. I have tried {{user.email}} in the html file, but error says Error: Error in ./PostsComponent class PostsComponent - inline template:12:39 caused by: undefined is not an object (evaluating 'self.context.user.email').

@jakobsen9
Copy link
Author

@ploer Hi, documentation on how to access and use the attributes are really missing...

@pdspicer
Copy link
Contributor

How you use the attributes after returning a value from the verify callback is really dependent on your passport configuration. Default behavior is that req.user is populated after a successful call to passport.authenticate(), which you can certainly then return to your front-end however you'd like.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants