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

Specifying multiple attributes #15

Open
td512 opened this issue Oct 3, 2020 · 2 comments
Open

Specifying multiple attributes #15

td512 opened this issue Oct 3, 2020 · 2 comments

Comments

@td512
Copy link

td512 commented Oct 3, 2020

Is there any way to specify multiple attributes in respond_to?

I'd like to be passing on in an email and first name, but at the moment I've only been able to do that with the email, my code's below for reference

      response = SAML2::Response.respond_to(authn_request,
                                            SAML2::NameID.new(self.class.entity_id(@sp)),
                                            self.class.idp_name_email(@user), @sp.redirect_uri)
@td512
Copy link
Author

td512 commented Oct 11, 2020

@ccutrer?

@ccutrer
Copy link
Contributor

ccutrer commented Oct 12, 2020

response = SAML2::Response.respond_to(authn_request,
                                              issuer, subject, attributes)

is working just fine for us. I'm not sure why we're passing in the redirect uri there, but the fourth argument is an attributes hash that is passed to AttributeConsumingService#create_statement. Note that in order for it to work, you need to have previously called AuthnRequest#resolve on the authn_request, and that the ServiceProvider object passed in to that call has to have an attribute consuming service with the attributes defined that should be sent to this ServiceProvider. It's designed this way so that you can pass a big hash of all attributes you support to respond_to, and then if you integrate with multiple SPs the code will automatically only send the attributes this particular provider wants. The values of the attribute hash can be Procs as well, so that they're only evaluated if they're actually needed.

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

2 participants