私はスリムフレームワーク3でこのようにそれをやった:私はすべての要求にミドルウェアを追加し、特定の文字列をAuthorizationヘッダーを確認
とAuthorizationヘッダーが設定されていないか、私はちょうど私の文字列に一致doesntの場合HTTPコード400を返します。
$app->add(function($request,$response,$next){
$authorization_header = $request->getHeader("Authorization");
if(empty($authorization_header) || ($authorization_header[0]!="test")){ //you can check the header for a certain string or you can check if what is in the Authorization header exists in your database
return $response->withStatus(400);
}
$response = $next($request,$response);
return $response;
});
1のコードでは、以上の千の言葉を言うことができます。..加える[MCVE] – Xorifelse
あなたは$要求 - >のgetHeader [$ nameOfHeaderKey]を試みたことがありますか? – Rob