Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dex
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
dex
Commits
6f9ef961
Commit
6f9ef961
authored
Mar 22, 2017
by
Phu Kieu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Use etreeutils.NSSelectOne to select Assertion element
parent
4b457d8c
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
22 additions
and
2 deletions
+22
-2
saml.go
connector/saml/saml.go
+4
-2
saml_test.go
connector/saml/saml_test.go
+4
-0
oam-ca.pem
connector/saml/testdata/oam-ca.pem
+13
-0
oam-resp.xml
connector/saml/testdata/oam-resp.xml
+1
-0
No files found.
connector/saml/saml.go
View file @
6f9ef961
...
...
@@ -17,6 +17,7 @@ import (
"github.com/Sirupsen/logrus"
"github.com/beevik/etree"
dsig
"github.com/russellhaering/goxmldsig"
"github.com/russellhaering/goxmldsig/etreeutils"
"github.com/coreos/dex/connector"
)
...
...
@@ -500,8 +501,9 @@ func verify(validator *dsig.ValidationContext, data []byte) (signed []byte, err
verified
=
true
doc
.
SetRoot
(
transformedResponse
)
}
assertion
:=
response
.
SelectElement
(
"Assertion"
)
if
assertion
==
nil
{
// Ensures xmlns are copied down to the assertion element when they are defined in the root
assertion
,
err
:=
etreeutils
.
NSSelectOne
(
response
,
"urn:oasis:names:tc:SAML:2.0:assertion"
,
"Assertion"
)
if
err
!=
nil
{
return
nil
,
fmt
.
Errorf
(
"response does not contain an Assertion element"
)
}
transformedAssertion
,
err
:=
validator
.
Validate
(
assertion
)
...
...
connector/saml/saml_test.go
View file @
6f9ef961
...
...
@@ -86,6 +86,10 @@ func TestVerify(t *testing.T) {
runVerify
(
t
,
"testdata/okta-ca.pem"
,
"testdata/okta-resp.xml"
,
true
)
}
func
TestVerifyUnsignedMessageAndSignedAssertionWithRootXmlNs
(
t
*
testing
.
T
)
{
runVerify
(
t
,
"testdata/oam-ca.pem"
,
"testdata/oam-resp.xml"
,
true
)
}
func
TestVerifySignedMessageAndUnsignedAssertion
(
t
*
testing
.
T
)
{
runVerify
(
t
,
"testdata/idp-cert.pem"
,
"testdata/idp-resp-signed-message.xml"
,
true
)
}
...
...
connector/saml/testdata/oam-ca.pem
0 → 100644
View file @
6f9ef961
-----BEGIN CERTIFICATE-----
MIIB/jCCAWegAwIBAgIBCjANBgkqhkiG9w0BAQQFADAkMSIwIAYDVQQDExlkZWFv
YW0tZGV2MDIuanBsLm5hc2EuZ292MB4XDTE2MDYzMDA0NTQxNloXDTI2MDYyODA0
NTQxNlowJDEiMCAGA1UEAxMZZGVhb2FtLWRldjAyLmpwbC5uYXNhLmdvdjCBnzAN
BgkqhkiG9w0BAQEFAAOBjQAwgYkCgYEAht1N4lGdwUbl7YRyHwSCrnep6/e2I3+V
eue0pSA/DGn8OuR/udM8UCja5utqlqJdq200ox4b4Mpz0Jg9kMckALtKe+1DgeES
EIx9FpeuBdHlitYQNSbEr30HIG2nmeTOy4Vi5unBO54um3tNazcUTMA0/LJ6KQL8
LeZSlB/IxwUCAwEAAaNAMD4wDAYDVR0TAQH/BAIwADAPBgNVHQ8BAf8EBQMDB9gA
MB0GA1UdDgQWBBRYo1YjfrNonauLzj6/AsueWFGSszANBgkqhkiG9w0BAQQFAAOB
gQACq7GHK/Zsg0+qC0WWa2ZjmOXE6Dqk/xuooG49QT7ihABs7k9U27Fw3xKF6MkC
7pca1FwT82eZK1N3XKKpZe7Flu1fMKt2o/XSiBkDjWwUcChVnwGsUBe8hJFwFqg7
olNJn1kaVBJUqZIiXF9kS0d+1H55rStOd0CNXAzp9utr2A==
-----END CERTIFICATE-----
connector/saml/testdata/oam-resp.xml
0 → 100644
View file @
6f9ef961
<samlp:Response
xmlns:samlp=
"urn:oasis:names:tc:SAML:2.0:protocol"
xmlns:dsig=
"http://www.w3.org/2000/09/xmldsig#"
xmlns:enc=
"http://www.w3.org/2001/04/xmlenc#"
xmlns:saml=
"urn:oasis:names:tc:SAML:2.0:assertion"
xmlns:x500=
"urn:oasis:names:tc:SAML:2.0:profiles:attribute:X500"
xmlns:xsi=
"http://www.w3.org/2001/XMLSchema-instance"
Destination=
"http://127.0.0.1:5556/callback"
ID=
"id-IWlPTptSB-PlR80dwt8ZhVeG70mrz7nPvTVrhduK"
InResponseTo=
"_e66b3a98-831c-4c96-5706-b63fe0549624"
IssueInstant=
"2016-12-12T16:54:35Z"
Version=
"2.0"
><saml:Issuer
Format=
"urn:oasis:names:tc:SAML:2.0:nameid-format:entity"
>
https://deaoam-dev02.jpl.nasa.gov:14101/oam/fed
</saml:Issuer><samlp:Status><samlp:StatusCode
Value=
"urn:oasis:names:tc:SAML:2.0:status:Success"
/></samlp:Status><saml:Assertion
ID=
"id-rT9rTqxdQC9j34YhVeNayUWC9EbIBgym6gp-MZt-"
IssueInstant=
"2016-12-12T16:54:35Z"
Version=
"2.0"
><saml:Issuer
Format=
"urn:oasis:names:tc:SAML:2.0:nameid-format:entity"
>
https://deaoam-dev02.jpl.nasa.gov:14101/oam/fed
</saml:Issuer><dsig:Signature><dsig:SignedInfo><dsig:CanonicalizationMethod
Algorithm=
"http://www.w3.org/2001/10/xml-exc-c14n#"
/><dsig:SignatureMethod
Algorithm=
"http://www.w3.org/2000/09/xmldsig#rsa-sha1"
/><dsig:Reference
URI=
"#id-rT9rTqxdQC9j34YhVeNayUWC9EbIBgym6gp-MZt-"
><dsig:Transforms><dsig:Transform
Algorithm=
"http://www.w3.org/2000/09/xmldsig#enveloped-signature"
/><dsig:Transform
Algorithm=
"http://www.w3.org/2001/10/xml-exc-c14n#"
/></dsig:Transforms><dsig:DigestMethod
Algorithm=
"http://www.w3.org/2000/09/xmldsig#sha1"
/><dsig:DigestValue>
z1HD/59hv6UOd5+jeG+ihaFWLgI=
</dsig:DigestValue></dsig:Reference></dsig:SignedInfo><dsig:SignatureValue>
I99oG5kiOfIgbXYa21z/TOmzftTkFnXe9ObhBNSKit9kAhT93apYROqqXv4Ax96P144Ld7ERX1hgJsytK8LC2874Pk7QrSNm4zvW3x0D4GR4lM06CvJK/EhIur3TrCUJDPigvyP7TJitheCyBejwt0x0lqNP/OzR3tMbAIMRoho=
</dsig:SignatureValue></dsig:Signature><saml:Subject><saml:NameID
Format=
"urn:oasis:names:tc:SAML:2.0:nameid-format:persistent"
NameQualifier=
"https://deaoam-dev02.jpl.nasa.gov:14101/oam/fed"
SPNameQualifier=
"JSAuth"
>
pkieu
</saml:NameID><saml:SubjectConfirmation
Method=
"urn:oasis:names:tc:SAML:2.0:cm:bearer"
><saml:SubjectConfirmationData
InResponseTo=
"_e66b3a98-831c-4c96-5706-b63fe0549624"
NotOnOrAfter=
"2016-12-12T16:59:35Z"
Recipient=
"http://127.0.0.1:5556/callback"
/></saml:SubjectConfirmation></saml:Subject><saml:Conditions
NotBefore=
"2016-12-12T16:54:35Z"
NotOnOrAfter=
"2016-12-12T16:59:35Z"
><saml:AudienceRestriction><saml:Audience>
JSAuth
</saml:Audience></saml:AudienceRestriction></saml:Conditions><saml:AuthnStatement
AuthnInstant=
"2016-12-12T16:54:10Z"
SessionIndex=
"id-l3NCbxKoBfUZcuKhlotMuIF3ydgYJgGGG6BGTTU6"
SessionNotOnOrAfter=
"2016-12-12T17:54:35Z"
><saml:AuthnContext><saml:AuthnContextClassRef>
urn:oasis:names:tc:SAML:2.0:ac:classes:PasswordProtectedTransport
</saml:AuthnContextClassRef></saml:AuthnContext></saml:AuthnStatement></saml:Assertion></samlp:Response>
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment