-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathroute_list.php
99 lines (70 loc) · 2.75 KB
/
route_list.php
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
98
<?php
namespace BlueRaster\PowerBIAuthProxy;
use BlueRaster\PowerBIAuthProxy\Admin\AdminRoute;
use BlueRaster\PowerBIAuthProxy\Installers\Installer;
class DefaultRoute extends Route{
public $report_id;
public $method_name;
protected $nullable_methods = ["asset"];
public function __construct(){
parent::__construct('^\/auth_proxy_routes\/(.*?)$', ['auth_proxy_gate'], null);
$path = rtrim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/');
$matched = preg_match('/^\/auth_proxy_routes\/(.*?)\/(.*?)$/i', $path, $matches);
if($matched){
$this->method_name = @$matches[1];
$this->report_id = @$matches[2];
}
$this->nullable = in_array($this->method_name, $this->nullable_methods);
}
// responds to the url: /auth_proxy_routes/embed_data
public function embed_data(){
$reports = DB::get('reports');
if(empty($reports)){
$reports_string = Auth::config('selected_reports');
$selected_reports = array_map(function($v){
return Embed::createFromString($v);
}, Utils::clean_array_from_string($reports_string));
}
else{
$selected_reports = $reports->map(function($v){
return new Embed($v);
});
}
return collect($selected_reports);
}
// responds to the url: /auth_proxy_routes/current_user
public function current_user(Routes $routes){
return Auth::getCurrentUser();
}
// responds to the url: /auth_proxy_routes/report_embed/{report_id}
public function report_embed($report_id = false, $router = null){
if($report_id === false) return false;
$auth_proxy = Auth::get_instance();
$embed_token = $auth_proxy->getEmbedToken($report_id);
return ['embed_token' => $embed_token, 'report_id' => $report_id, 'group_id' => Auth::config('group_id')];
}
// responds to the url: /auth_proxy_routes/esri_embed/{report_id}
// deprecated: will not allow access without login
public function esri_embed($report_id = false){
if($report_id === false) return false;
$auth_proxy = Auth::get_instance();
$embed_token = $auth_proxy->getEsriEmbedToken($report_id);
return ['access_token' => $embed_token, 'report_id' => $report_id];
}
// responds to the url: /auth_proxy_routes/asset/{secure_embed.js|secure_embed.css}
public function asset($filename){
$this->nullable = true;
$ok = preg_match('/^secure_embed.*?\.(js|css|js\.map|css\.map)$/', $filename, $match);
if(!$ok) return false;
return @file_get_contents(__DIR__."/assets/dist/$filename");
}
// responds to the url: /auth_proxy_routes/app_update
public function app_update(){
return [
'update_available' => (new Installer)->web_update_available(),
];
}
}
// responds to the url: /auth_proxy_routes/auth_proxy_admin.html
new AdminRoute;
new DefaultRoute();