@@ -120,6 +120,35 @@ public function testAuthenticationCustomCredentialsKey()
120
120
$ this ->assertEquals ('cert@example.com ' , $ passport ->getUser ()->getUserIdentifier ());
121
121
}
122
122
123
+ /**
124
+ * @dataProvider provideServerVarsUserIdentifier
125
+ */
126
+ public function testAuthenticationCustomCredentialsUserIdentifier ($ username , $ credentials )
127
+ {
128
+ $ authenticator = new X509Authenticator ($ this ->userProvider , new TokenStorage (), 'main ' , 'SSL_CLIENT_S_DN_Email ' , 'SSL_CLIENT_S_DN ' , null , 'CN ' );
129
+
130
+ $ request = $ this ->createRequest ([
131
+ 'SSL_CLIENT_S_DN ' => $ credentials ,
132
+ ]);
133
+ $ this ->assertTrue ($ authenticator ->supports ($ request ));
134
+
135
+ $ this ->userProvider ->createUser (new InMemoryUser ($ username , null ));
136
+
137
+ $ passport = $ authenticator ->authenticate ($ request );
138
+ $ this ->assertEquals ($ username , $ passport ->getUser ()->getUserIdentifier ());
139
+ }
140
+
141
+ public static function provideServerVarsUserIdentifier ()
142
+ {
143
+ yield ['Sample certificate DN ' , 'CN=Sample certificate DN/emailAddress=cert@example.com ' ];
144
+ yield ['Sample certificate DN ' , 'CN=Sample certificate DN/emailAddress=cert+something@example.com ' ];
145
+ yield ['Sample certificate DN ' , 'CN=Sample certificate DN,emailAddress=cert@example.com ' ];
146
+ yield ['Sample certificate DN ' , 'CN=Sample certificate DN,emailAddress=cert+something@example.com ' ];
147
+ yield ['Sample certificate DN ' , 'emailAddress=cert+something@example.com,CN=Sample certificate DN ' ];
148
+ yield ['Firstname.Lastname ' , 'emailAddress=firstname.lastname@mycompany.co.uk,CN=Firstname.Lastname,OU=london,OU=company design and engineering,OU=Issuer London,OU=Roaming,OU=Interactive,OU=Users,OU=Standard,OU=Business,DC=england,DC=core,DC=company,DC=co,DC=uk ' ];
149
+ yield ['user1 ' , 'C=FR, O=My Organization, CN=user1, emailAddress=user1@myorg.fr ' ];
150
+ }
151
+
123
152
private function createRequest (array $ server )
124
153
{
125
154
return new Request ([], [], [], [], [], $ server );
0 commit comments