Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SAML Request Attributes In AuthnRequest

I kind of understand how basic SAML authentication supposed to work:

User request resource at SP
SP sends auth request to IDP
IDP authenticates user and sends back some userId
SP sends attribute query to IDP for additional details with userId
IDP sends back attributes
SP gives user resource

My issue is, can you any way bypass AttributeQuery. When I make a SAML 2.0 request to my testing Gluu/Shibboleth server, I get back givenName (firstname) and sn (lastname). Is there anyway I can request inum user id and email in just the AuthnRequest?

My request is pretty simple:

<samlp:AuthnRequest xmlns:samlp="urn:oasis:names:tc:SAML:2.0:protocol" xmlns:saml="urn:oasis:names:tc:SAML:2.0:assertion" ID="MyPrefix1457456412304" Version="2.0" IssueInstant="2016-03-08T17:00:12Z" ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST">
   <saml:Issuer>me.com</saml:Issuer>
</samlp:AuthnRequest>

Request I get back is something like this:

<?xml version="1.0" encoding="UTF-8"?>
<saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion" ID="_bff09cf745ea5722aac3f3ec57c0ecf3" IssueInstant="2016-03-08T17:01:06.140Z" Version="2.0">
    <saml2:Issuer ....
    <saml2:AttributeStatement>
        <saml2:Attribute FriendlyName="sn" Name="urn:oid:2.5.4.4" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
            <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">User</saml2:AttributeValue>
        </saml2:Attribute>
        <saml2:Attribute FriendlyName="givenName" Name="urn:oid:2.5.4.42" NameFormat="urn:oasis:names:tc:SAML:2.0:attrname-format:uri">
            <saml2:AttributeValue xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:type="xs:string">Admin</saml2:AttributeValue>
        </saml2:Attribute>
    </saml2:AttributeStatement>
</saml2:Assertion>

I read the relevant part of the spec, and it seems to say the server can give back whatever it wants really (and how many attributes it wants)? Again, my question is whether I can force the SAML Gluu/Shibboleth server to give me back specific attributes as part of AuthnRequest.

like image 684
jn1kk Avatar asked Mar 08 '16 17:03

jn1kk


People also ask

What are attributes in SAML?

An attribute is a characteristic or trait of an entity that describes the entity. It is a name:value pair. The attributes included in the SAML assertion correspond to certain attributes of the service provider to: Convey user information from Verify to the service provider .

What is SAML AuthnRequest?

SAML AuthNRequest (SP -> IdP)An AuthnRequest is sent by the Service Provider to the Identity Provider in the SP-SSO initiated flow. There are 2 examples: An AuthnRequest with its Signature (HTTP-Redirect binding). An AuthNRequest with the signature embedded (HTTP-POST binding).

How SAML request is created?

A SAML Request, also known as an authentication request, is generated by the Service Provider to "request" an authentication. A SAML Response is generated by the Identity Provider. It contains the actual assertion of the authenticated user.

What is destination in SAML request?

Destination (defined in saml 2 core lines 1477-1482) Destination is URL of the endpoint you are sending the message to. Typically SAML peers have different endpoints for different bindings and the value is used at IDP to verify that the received message was actually intended for the place where it was received.


Video Answer


2 Answers

You need to add the wanted attributes to the released attributes in your Trust Relationship on the IdP. Afaik there's no way to specifically request attributes.

like image 193
A K Avatar answered Nov 20 '22 01:11

A K


Just to provide a bit more detail, the time for you to request additional attributes as the SP is when you send your metadata to the IdP. That metadata describes your service, to include the ACS endpoint, the public certificate that your AuthnRequests will be signed with, the certificate that you want your partner to encrypt with, the attributes that you require, your unique entity ID, etc. The nice thing is that once you determine what your service needs, this metadata doesn't have to change - for ANY partner. You can send it to everyone you partner with.

Once your partner receives this metadata, they import it, and fulfill the attributes you requested with information out of their identity repository, configure the signing and encryption, etc. Once everything is done they send their metadata to you, which contains their protocol endpoints (where you need to send AuthnRequests, etc., to), the certificate that can validate their signing, validation of the attributes that they are sending to you (these can change, based on conversations that you should be holding with your partner) etc.

You get this metadata, and import it into your system, and build out the connection(s) to your apps as needed.

like image 36
Andrew K. Avatar answered Nov 20 '22 03:11

Andrew K.