-
Notifications
You must be signed in to change notification settings - Fork 55
Expand file tree
/
Copy pathweb.php
More file actions
97 lines (72 loc) · 2.81 KB
/
Copy pathweb.php
File metadata and controls
97 lines (72 loc) · 2.81 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/
use Lcobucci\JWT\Builder;
use Lcobucci\JWT\Signer\Hmac\Sha256;
use Lcobucci\JWT\Signer\Key;
Route::get('/', function () {
$metabaseSiteUrl = 'http://localhost:3000';
$metabaseSecretKey = 'a1c0952f3ff361f1e7dd8433a0a50689a004317a198ecb0a67ba90c73c27a958';
$signer = new Sha256();
$token = (new Builder())
->withClaim('resource', [
'dashboard' => 1
])
->withClaim('params', [
'params' => (object)[]
])
->getToken($signer, new Key($metabaseSecretKey));
$iframeUrl = "{$metabaseSiteUrl}/embed/dashboard/{$token}#bordered=true&titled=true";
return view('welcome', compact('iframeUrl'));
});
Route::get('signed_dashboard/{userId}', function($userId) {
$metabaseSiteUrl = 'localhost:3000';
$metabaseSecretKey = 'a1c0952f3ff361f1e7dd8433a0a50689a004317a198ecb0a67ba90c73c27a958';
$signer = new Sha256();
$token = (new Builder())
->withClaim('resource', [
'dashboard' => 2
])
->withClaim('params', [
'id' => $userId
])
->getToken($signer, new Key($metabaseSecretKey));
$iframeUrl = "{$metabaseSiteUrl}/embed/dashboard/{$token}#bordered=true";
return view('signed_dashboard', compact('iframeUrl', 'userId'));
});
Route::get('signed_chart/{userId}', function($userId) {
$metabaseSiteUrl = 'localhost:3000';
$metabaseSecretKey = 'a1c0952f3ff361f1e7dd8433a0a50689a004317a198ecb0a67ba90c73c27a958';
$signer = new Sha256();
$token = (new Builder())
->withClaim('resource', [
'question' => 2
])
->withClaim('params', [
'person_id' => $userId
])
->getToken($signer, new Key($metabaseSecretKey));
$iframeUrl = "{$metabaseSiteUrl}/embed/question/{$token}#bordered=true&titled=true";
return view('signed_chart', compact('iframeUrl', 'userId'));
});
Route::get('signed_public_dashboard', function() {
$metabaseSiteUrl = 'localhost:3000';
$metabaseSecretKey = 'a1c0952f3ff361f1e7dd8433a0a50689a004317a198ecb0a67ba90c73c27a958';
$signer = new Sha256();
$token = (new Builder())
->withClaim('resource', [
'dashboard' => 1
])
->withClaim('params', (object)[])
->getToken($signer, new Key($metabaseSecretKey));
$iframeUrl = "{$metabaseSiteUrl}/embed/dashboard/{$token}#bordered=true&titled=true";
return view('signed_public_dashboard', compact('iframeUrl'));
});