Hi there,
working on a REST portion of an App, I’ve stumbled upon a nice problem:
[
'class' => 'yii\rest\UrlRule',
'controller' => 'users-manager',
'tokens' => [
'{token}' => '<token:\w+>',
'{username}' => '<username:\S+>',
'{password}' => '<password:[\S\s]+>',
'{persistent}' => '<persistent:\d>'
],
'extraPatterns' => [
'POST login/{username}/{password}/{persistent}' => 'login',
...
'POST logout/{token}' => 'logout',
]
]
Now, when I want to call it from the client:
$client = curl_init();
curl_setopt( $client, CURLOPT_POST, True );
curl_setopt( $client, CURLOPT_URL, "https://.../users-manager/login/" );
curl_setopt( $client, CURLOPT_RETURNTRANSFER, True );
$data = [
"username" => "john",
"password" => <password>,
"persistent" => ( $remember ? "1" : "0" )
];
curl_setopt( $client, CURLOPT_POSTFIELDS, $data );
$response = curl_exec( $client );
The server response with a HTTP/404 (Not found) because it seems doesn’t match with the URL pattern. Of course, if I issue:
$client = curl_init( https://.../users-manager/login/{$username}/{$password}/ . ( $remember ? 1 : 0 ) );
curl_setopt( $client, CURLOPT_RETURNTRANSFER, True );
curl_setopt( $client, CURLOPT_POST, True );
$response = curl_exec( $client );
it works flawlessly but exposes the user credentials in the proxy/web server log.
Is there any work around?
Really appreciate any help,
S.