免責事項:私はWeb開発を初めて利用しています。CodeIgniterアプリケーションのURLセキュリティ
シナリオ:イベントカレンダーとして最もよく説明されるCodeIgniterを使用してアプリケーションを構築しました。アプリケーションには、イベントカレンダーを他の人と共有できる共有機能があります。ログインすると、ユーザーは共有ページに移動し、イベントカレンダーを共有しているユーザーのリストから選択できます。ユーザーは彼らと彼らのイベントカレンダーを共有している人の名前を選択したときに、現在、以下のURIが生成されます。
http://example.com/folder/controller/method/id
id
セクションでは、自分が共有しているユーザーのデータベースでowner_id
です個人とのカレンダー。
問題:URLのid
セクションを別のユーザーのowner_id
データベースに変更するのは簡単です。これにより、誰でもイベントカレンダーの共有を許可していない個人のイベントカレンダーにアクセスできます。
質問:このセキュリティギャップを解決する方法はありますか?私が提供する必要があるものが他にあるかどうか教えてください。また、より明確な方法で説明してください。あなたの時間とエネルギーに感謝します。
モデル:
class Shares_model extends crud_model {
public function __construct()
{
parent::__construct();
$this->pk = 'id';
$this->table_name = 'shares';
}
public function get($shared_to_user_id)
{
$this->db->where('shared_to_id', $shared_to_user_id);
$ids = parent::get_all();
$users = array();
foreach ($ids as $id)
{
$users[$id->owner_id]['owner_id'] = $id->owner_id;
$users[$id->owner_id]['owner_first_name'] = $id->owner_first_name;
$users[$id->owner_id]['owner_last_name'] = $id->owner_last_name;
}
return $users;
}
}
ビュー:
<div class="panel">
<h4>Shared Planners</h4>
<ol>
<?php foreach($sharers as $s): ?>
<li><a href="<?php echo base_url('user/shared/view/'.$s['owner_id']) ?>"><strong><?php echo $s['owner_first_name']." ".$s['owner_last_name'] ?></strong></a></li>
<?php endforeach; ?>
</ol>
</div>
コントローラー:あなたはキープテーブルを持つことができ
class Shared extends Common_Auth_Controller {
private $end_user;
public function __construct()
{
parent::__construct();
$this->end_user = $this->ion_auth->user()->row();
$data['end_user'] = $this->end_user;
$this->load->vars($data);
$this->load->model('events_model', 'events');
}
public function index()
{
$title['title'] = 'Shared';
$this->load->model('shares_model','shares');
$data['sharers'] = $this->shares->get($this->end_user->id);
$this->load->view('public/head_view', $title);
$this->load->view('user/header_view');
$this->load->view('user/shared_view', $data);
$this->load->view('user/footer_view');
}
あなたのイベント/カレンダーの認証テーブルを持っているのはなぜですか? – Peter