php - How to securely share a link to others - Laravel 5 -
hi making call recording system, basically, there's admin , user. admin upload call recording file stored in file system. admin assign user call recording user can see.
so in database have
recordingstable ->id ->name ->path ->filename
then designation table store assigned call recording user.
designationtable ->id ->user_id ->recording_id
i make function user can see , play recording assigned him/her. problem user share recording else. done that, loading the assigned recording user, , in his/her dashboard there's public link video,
<a href="http://localhost/callrec/public/recording/{!! $value->recordid !!}">see public link</a>
as can see i'm using blade template. can
$value->recordid
recording id resource, let's link directed to
http://localhost/callrec/public/recording/1
then link public , user can share it. there's risk, when he/she shared id
link can altered, let's http://localhost/callrec/public/recording/4
, if id
existing can accessed supposed not coz user shared id = 1
. how approach problems this? ideas , suggestions? thanks!
if use id in url, noticed it's easy guess other possible ids, change url , access other recordings. need share links containing value users won't able guess. 1 example hash of recording id using secret value hash - e.g. app_key value.
what need is:
- add string hash column recording table
when recording created, calculate hash , save recording:
$recording = recording::create($attributes); $recording->hash = base64_encode(hash::make ($recording->recordid . config::get('app_key'))); $recording->save();
use hash in urls
<a href="http://localhost/callrec/public/recording/{!! $value->hash!!}"> see public link </a>
this way links publicly available, guessing hash of recording more or less hard guessing passwords in application same logic applied. make sure keep app_key safe.
Comments
Post a Comment