我正在写一个小sms网关,供几个项目使用,
我实施了laravel护照认证(client credentials grant token)
然后我将CheckClientCredentials添加到api中间件组:
protected $middlewareGroups = [ 'web' => [ ... ],'api' => [ 'throttle:60,1','bindings',\Laravel\Passport\Http\Middleware\CheckClientCredentials::class ],];
逻辑工作正常,现在在我的控制器中我需要让客户端与有效令牌相关联.
Route::post('/sms',function(Request $request) { // save the sms along with the client id and send it $client_id = ''; // get the client id somehow sendSms($request->text,$request->to,$client_id); });
出于明显的安全原因,我永远不能使用消费者请求发送客户端ID,例如$client_id = $request-> client_id;.