WSSE auth in Symfony2, how to create the correct headers?

I follow the Symfony 2 cookbook user authentication manufacturer , but I have no idea how to create a login form or something with the proper WSSE headers required, so I can pass this on to my custom provider.

Any documents or tutorials on this? Maybe some examples? The documentation does not contain such information.

+4
source share
2 answers

In fact, you should not use the login form to send WSSE headers to your server: the login form will send an HTTP POST request (with POST parameters), but will not change the HTTP headers as expected using a WSSE connection.

I am using WSSE with javascript and / or some client, like Android apps.

For testing, I use curl on the command line, adding wsse headers to the request.

Here is another question / answer that should help you manipulate zaviv, and help javascript wsse generator .

+3
source

Hi, an example of a PHP Client WSSE generator with Symfony

function hashPassword($password, $salt) { $salted = $password . '{' . $salt . '}'; $digest = hash('sha512', $salted, true); //5000 iterations: the sysmfony default iterations for ($i = 1; $i < 5000; $i++) { $digest = hash('sha512', $digest . $salted, true); } return base64_encode($digest); } function wsse_header($username, $hashedPassword) { $nonce = hash_hmac('sha512', uniqid(null, true), uniqid(), true); $created = new DateTime('now', new DateTimezone('UTC')); $created = $created->format(DateTime::ISO8601); $digest = hash('sha512', $nonce . $created . $hashedPassword, true); return sprintf( 'X-WSSE: UsernameToken Username="%s", PasswordDigest="%s", Nonce="%s", Created="%s"', $username, base64_encode($digest), base64_encode($nonce), $created ); } echo wsse_header('someUsername', hashPassword('somePassword', 'someSalt')); 

You can adapt this example to other clients (Android, Ios, Javascript, ...)

+1
source

All Articles