Question

Okta is an IdP for SAML logins. I have a super-admin user of Okta.

I try to use Spring's saml-sample project as my SP (service-provider). When I configure it (spring-saml-sample) in the Okta system, I need to supply some data on my SP, such as "post back URL", "recipient" and "audience restriction".

After sniffing in Okta's docs, I found this:

Audience Restriction – This is the entity id of the Service Provider. It will be provided by the SP and must match exactly. Consult the SP documentation to get this information.

Recipient –Enter the service provider’s assertion consumer service URL . Consult the SP documentation to get this information. So I figured out that this URL should be: http://srv101.watchdox.net/spring-security-saml2-sample/saml/SSO/alias/defaultAlias

Post Back URL – This is the SAML SP endpoint (i.e. where your users will log in)

Destination for the SAML response – This is the intended destination of the saml assertion. Unless specified by the SP, this will typically be identical to the post back URL. Consult the SP documentation to get this information.

The Problem:

My app (spring-saml-sample) has a "welcome" page, where the user chooses the IdP he wants to login with. So I choose "Okta" IdP, and then i am redirected to the Okta to log-in (perfect till here), but after login, instead of redirecting me back to my app (to the protected resource), I stay in the Okta system and see their framework. I do see my app there. When I click on it, I get to my first page, to choose the IdP.

I believe the problem is with my URLs, or with the SAML response... Anyonw has an idea?

Pasted here the Request and response, if might be helpfull.

I pasted here the SAML requests and responses, in case it might be helpfull. Note that the Status Code in the response is "Success"!

What can be wrong? what am I missing?

Request:

POST https://watchdox.okta.com/app/template_saml_2_0/k3gvyf0mGFVVCVQBYTTA/sso/saml HTTP/1.1
Host: watchdox.okta.com
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Referer: https://srv101.watchdox.net/spring-security-saml2-sample/saml/login/alias/defaultAlias?idp=http%3A%2F%2Fwww.okta.com%2Fk3gvyf0mGFVVCVQBYTTA
Content-Type: application/x-www-form-urlencoded
Content-Length: 3906

HTTP/?.? 200 OK
Server: nginx/1.2.6
Date: Thu, 18 Apr 2013 08:49:39 GMT
Content-Type: text/html;charset=utf-8
Transfer-Encoding: chunked
Connection: keep-alive
P3P: CP="HONK"
Set-Cookie: sid=""; Expires=Thu, 01-Jan-1970 00:00:10 GMT; Path=/
t=default; Path=/
X-Okta-backend: webapp09e.prod.saasure.com
Cache-Control: no-cache, public
Pragma: no-cache
Expires: 0
Content-Language: en-US
Content-Encoding: gzip

SAML request:

<saml2p:AuthnRequest xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
                     AssertionConsumerServiceURL="https://srv101.watchdox.net:443/spring-security-saml2-sample/saml/SSO/alias/defaultAlias"
                     Destination="https://watchdox.okta.com/app/template_saml_2_0/k3gvyf0mGFVVCVQBYTTA/sso/saml"
                     ForceAuthn="false"
                     ID="a32a5d9jfge33c9b46gdaddid8gd41b"
                     IsPassive="false"
                     IssueInstant="2013-04-18T08:49:38.141Z"
                     ProtocolBinding="urn:oasis:names:tc:SAML:2.0:bindings:HTTP-POST"
                     Version="2.0"
                     >
    <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">com.watchdox.ohad</saml2:Issuer>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
            <ds:Reference URI="#a32a5d9jfge33c9b46gdaddid8gd41b">
                <ds:Transforms>
                    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                <ds:DigestValue>blwZT1B5451jbzeB9m0ogyGQuFY=</ds:DigestValue>
            </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>RZeXySsMfy+iBglUngrCHg2XoaA4WzAkLrB/zhjRfqFQS45avePlF8f19N+MHoF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XN3wIY+/R93vBA6lnl5nTctZIRsyg
0Gv5AgMBAAEwDQYJKoZIhvcNAQEFBQADggEBAFQwAAYUjso1VwjDc2kypK/RRcB8bMAUUIG0hLGL
82IvnKouGixGqAcULwQKIvTs6uGmlgbSG6Gn5ROb2mlBztXqQ49zRvi5qWNRttir6eyqwRFGOM6A
8rxj3Jhxi2Vb/MJn7XzeVHHLzA1sV5hwl/2PLnaL2h9WyG9QwBbwtmkMEqUt/dgixKb1Rvby/tBu
RogWgPONNSACiW+Z5o8UdAOqNMZQozD/i1gOjBXoF0F5OksjQN7xoQZLj9xXefxCFQ69FPcFDeEW
bHwSoBy5hLPNALaEUoa5zPDwlixwRjFQTc5XXaRpgIjy/2gsL8+Y5QRhyXnLqgO67BlLYW/GuHE=</ds:X509Certificate>
            </ds:X509Data>
        </ds:KeyInfo>
    </ds:Signature>
</saml2p:AuthnRequest>

Okta response:

POST http://srv101.watchdox.net/spring-security-saml2-sample/ HTTP/1.1
Host: srv101.watchdox.net
User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:20.0) Gecko/20100101 Firefox/20.0
Accept: text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate
Content-Type: application/x-www-form-urlencoded
Content-Length: 7863

HTTP/?.? 302 Found
Date: Thu, 18 Apr 2013 08:51:57 GMT
Server: Apache
Location: https://srv101.watchdox.net/spring-security-saml2-sample/
Content-Length: 241
Keep-Alive: timeout=30, max=100
Connection: Keep-Alive
Content-Type: text/html; charset=iso-8859-1

SAML Response:

<saml2p:Response xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol"
                 Destination="http://srv101.watchdox.net/spring-security-saml2-sample/"
                 ID="id141234960903909491594058959"
                 InResponseTo="a32a5d9jfge33c9b46gdaddid8gd41b"
                 IssueInstant="2013-04-18T08:51:49.819Z"
                 Version="2.0"
                 >
    <saml2:Issuer xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
                  Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"
                  >http://www.okta.com/k3gvyf0mGFVVCVQBYTTA</saml2:Issuer>
    <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
        <ds:SignedInfo>
            <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
            <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
            <ds:Reference URI="#id141234960903909491594058959">
                <ds:Transforms>
                    <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                    <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                </ds:Transforms>
                <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                <ds:DigestValue>nCrBE9jowt9QAOk5ipw1SFnb248=</ds:DigestValue>
            </ds:Reference>
        </ds:SignedInfo>
        <ds:SignatureValue>lwSHBmy4Hqt3XjbnPni6PePFFCn9hUJb7K4jh3xAyUum+y59TUYftphi00lFhnFZXsV5Tj75zLru3JX1jt7bdT73wsYS6ccNcyOvZpJvNiqbBeUmydK45DBrzIVxDA9CWS94+PTH4rrWT5+OEWURBxwhv9BiKiFrLb60YIp6Q3o=</ds:SignatureValue>
        <ds:KeyInfo>
            <ds:X509Data>
                <ds:X509Certificate>MIICmzCCAgSgAwIBAgIGAT1+4eJ9MA0GCSqGSIb3DQEBBQUAMIGQMQswCQYDVQQGEwJVUzETMBEG
A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEU
MBIGA1UECwwLU1NPUHJvdmlkZXIxETAPBgNVBAMMCHdhdGNoZG94MRwwGgYJKoZIhvcNAQkBFg1p
bmZvQG9rdGEuY29tMB4XDTEzMDMxODE5MDE0NVoXDTQzMDMxODE5MDI0NVowgZAxCzAJBgNVBAYT
AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQK
DARPa3RhMRQwEgYDVQQLDAtTU09Qcm92aWRlcjERMA8GA1UEAwwId2F0Y2hkb3gxHDAaBgkqhkiG
9w0BCQEWDWluZm9Ab2t0YS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL/raSnE0EXQ
mPgkSwyv8HIDPpmvU6prdySiWJSB3YztIC29VuneZbT0dFAOjAy6e/3NN7HjvBQU83YjhgBA43+U
f/7kwC2V8e5qi92J/pTrAWPB/UmTbCEVoCkR4BxSXr4bJ3dhk6eIPDGgOiuWjNCMTXoYX+aS1tsA
JDx0bXf5AgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAfiBOI+/mpP52Qsg6Ea1jVN/mGm4snvKl6Nlh
5sYGhGw5zXBVDU4pI9ulm/8QZsCAlYZXltZ+eif7CRzy2VZvDVMGH3g69AD2xHveYr8UNYSjnLyB
ZPpVJVOysH7UgtBqNcHm0l00g4uUV2d52WcDiz85q/KjTBB9OjRdGVhkcow=</ds:X509Certificate>
            </ds:X509Data>
        </ds:KeyInfo>
    </ds:Signature>
    <saml2p:Status xmlns:saml2p="urn:oasis:names:tc:SAML:2.0:protocol">
        <saml2p:StatusCode Value="urn:oasis:names:tc:SAML:2.0:status:Success" />
    </saml2p:Status>
    <saml2:Assertion xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
                     ID="id14123496090473949894445897"
                     IssueInstant="2013-04-18T08:51:49.819Z"
                     Version="2.0"
                     >
        <saml2:Issuer Format="urn:oasis:names:tc:SAML:2.0:nameid-format:entity"
                      xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
                      >http://www.okta.com/k3gvyf0mGFVVCVQBYTTA</saml2:Issuer>
        <ds:Signature xmlns:ds="http://www.w3.org/2000/09/xmldsig#">
            <ds:SignedInfo>
                <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
                <ds:Reference URI="#id14123496090473949894445897">
                    <ds:Transforms>
                        <ds:Transform Algorithm="http://www.w3.org/2000/09/xmldsig#enveloped-signature" />
                        <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#" />
                    </ds:Transforms>
                    <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />
                    <ds:DigestValue>D/wZzyBDL0RXwrf7d44mvuysYz0=</ds:DigestValue>
                </ds:Reference>
            </ds:SignedInfo>
            <ds:SignatureValue>DCrm/mkLiVsD8dAc4puY/L3GR1bxtDBn6+sTifLgxDGokFbS4PShjA3Ak6mTW1dM48TwXi1oB9Pz++iOP4w6ZVeBj9bWIPJaCATjWn26xBlt3GHaPjiOpUdvG5YwwqCMUlQ1+M0RhJDlkChfZbjPIKXibcP8TBIsj2sekr5sQSI=</ds:SignatureValue>
            <ds:KeyInfo>
                <ds:X509Data>
                    <ds:X509Certificate>MIICmzCCAgSgAwIBAgIGAT1+4eJ9MA0GCSqGSIb3DQEBBQUAMIGQMQswCQYDVQQGEwJVUzETMBEG
A1UECAwKQ2FsaWZvcm5pYTEWMBQGA1UEBwwNU2FuIEZyYW5jaXNjbzENMAsGA1UECgwET2t0YTEU
MBIGA1UECwwLU1NPUHJvdmlkZXIxETAPBgNVBAMMCHdhdGNoZG94MRwwGgYJKoZIhvcNAQkBFg1p
bmZvQG9rdGEuY29tMB4XDTEzMDMxODE5MDE0NVoXDTQzMDMxODE5MDI0NVowgZAxCzAJBgNVBAYT
AlVTMRMwEQYDVQQIDApDYWxpZm9ybmlhMRYwFAYDVQQHDA1TYW4gRnJhbmNpc2NvMQ0wCwYDVQQK
DARPa3RhMRQwEgYDVQQLDAtTU09Qcm92aWRlcjERMA8GA1UEAwwId2F0Y2hkb3gxHDAaBgkqhkiG
9w0BCQEWDWluZm9Ab2t0YS5jb20wgZ8wDQYJKoZIhvcNAQEBBQADgY0AMIGJAoGBAL/raSnE0EXQ
mPgkSwyv8HIDPpmvU6prdySiWJSB3YztIC29VuneZbT0dFAOjAy6e/3NN7HjvBQU83YjhgBA43+U
f/7kwC2V8e5qi92J/pTrAWPB/UmTbCEVoCkR4BxSXr4bJ3dhk6eIPDGgOiuWjNCMTXoYX+aS1tsA
JDx0bXf5AgMBAAEwDQYJKoZIhvcNAQEFBQADgYEAfiBOI+/mpP52Qsg6Ea1jVN/mGm4snvKl6Nlh
5sYGhGw5zXBVDU4pI9ulm/8QZsCAlYZXltZ+eif7CRzy2VZvDVMGH3g69AD2xHveYr8UNYSjnLyB
ZPpVJVOysH7UgtBqNcHm0l00g4uUV2d52WcDiz85q/KjTBB9OjRdGVhkcow=</ds:X509Certificate>
                </ds:X509Data>
            </ds:KeyInfo>
        </ds:Signature>
        <saml2:Subject xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion">
            <saml2:NameID Format="urn:oasis:names:tc:SAML:1.1:nameid-format:unspecified">OhadR@watchdox.com</saml2:NameID>
            <saml2:SubjectConfirmation Method="urn:oasis:names:tc:SAML:2.0:cm:bearer">
                <saml2:SubjectConfirmationData InResponseTo="a32a5d9jfge33c9b46gdaddid8gd41b"
                                               NotOnOrAfter="2013-04-18T08:56:49.819Z"
                                               Recipient="http://srv101.watchdox.net/spring-security-saml2-sample/saml/SSO/alias/defaultAlias"
                                               />
            </saml2:SubjectConfirmation>
        </saml2:Subject>
        <saml2:Conditions NotBefore="2013-04-18T08:46:49.819Z"
                          NotOnOrAfter="2013-04-18T08:56:49.819Z"
                          xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
                          >
            <saml2:AudienceRestriction>
                <saml2:Audience>com.watchdox.ohad</saml2:Audience>
            </saml2:AudienceRestriction>
        </saml2:Conditions>
        <saml2:AuthnStatement AuthnInstant="2013-04-18T08:51:49.819Z"
                              SessionIndex="a32a5d9jfge33c9b46gdaddid8gd41b"
                              xmlns:saml2="urn:oasis:names:tc:SAML:2.0:assertion"
                              >
            <saml2:AuthnContext>
                <saml2:AuthnContextClassRef>urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport</saml2:AuthnContextClassRef>
            </saml2:AuthnContext>
        </saml2:AuthnStatement>
    </saml2:Assertion>
</saml2p:Response>

Thanks for any answer!

Was it helpful?

Solution

If it might be helpful to someone in the future - I got it working now !!

I set all 3 URLs to the same one (as you suggested a week ago): https://srv101.watchdox.net:443/spring-security-saml2-sample/saml/SSO/alias/defaultAlias

so what is the difference, and why is it working now? because till now the URL I entered was http and not https (and without the 443): http://srv101.watchdox.net/spring-security-saml2-sample/saml/SSO/alias/defaultAlias

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top