RLS in Embeeding
we can directly define RLS when creating guesttokenÂ
public function getGuestToken()
{
$token = $this->login();
$response = Http::withHeaders([
'Content-Type' => 'application/json'
])->log()
->withToken($token)
->post("{$this->baseUrl}/api/v1/security/guest_token", [
'user' => [
'username' => '',
'first_name' => '',
'last_name' => ''
],
'resources' => [
[
'type' => 'dashboard',
'id' => $this->dashboardId
]
],
'rls' => [
['clause'=> 'fakultas = "Fakultas Kedokteran"']
] ,
]);
if ($response->successful()) {
return $response->json('token');
}
throw new \Exception('Failed to get guest token: ' . $response->body());
}
No Comments