- 登錄TSM添加受信任主機,保存后重啟
- 獲取受信任的賬戶票據
- 通過帶有票據資訊的url即可免登錄訪問Tableau(單點登錄)
方案: 客戶端à客戶端服務器à代理服務器(Nginx)à大資料服務器
Linux下Nginx配置(訪問https)
1.編譯:帶有ssl模塊
./configure --prefix=/usr/local/nginx --with-http_stub_status_module --with-http_ssl_module & make
2.修改nginx.conf 檔案
在Server節點中配置如下:
server {
listen 80;
server_name localhost;
access_log logs/access.log main;
error_log logs/error.log error;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
proxy_pass http://finereportpool;
root html;
index index.html index.htm;
}
location /bigdata {
proxy_pass https://xxx/xxx/; #需要代理的地址
root html;
index index.html index.htm;
}
}
停止nginx服務
指令:./nginx –s stop
替換編譯后的檔案:
替換nginx.conf 檔案
啟動nginx
指令:./nginx
重啟nginx
指令:./nginx -s reload
啟動nginx后訪問 http://xxx/xxx即可跳轉
配置受信任主機:
測驗獲取受信任用戶的IP:
撰寫測驗頁面:
<html>
<head>
<title>Trusted Ticket Requester</title>
<script type="text/javascript">
function submitForm(){
document.getElementById('form1').action =
document.getElementById('server').value + "/trusted";
}
</script>
<style type="text/css">
.style1 {width: 100%;}
.style2 {width: 429px;}
#server {width: 254px;}
</style>
</head>
<body>
<h3>Trusted Ticketer</h3>
<form method="POST" id="form1" onSubmit="submitForm()">
<table class="style1">
<tr>
<td class="style2">Username</td>
<td><input type="text" name="username" value="" /></td>
</tr>
<tr>
<td class="style2">Server</td>
<td><input type="text" id="server" name="server" value="https://" /></td>
</tr>
<tr>
<td class="style2">Client IP (optional)</td>
<td><input type="text" id="client_ip" name="client_ip" value="" /></td>
</tr>
<tr>
<td class="style2">Site (leave blank for Default site; otherwise enter the site name)</td>
<td><input type="text" id="target_site" name="target_site" value="" /></td>
</tr>
<tr>
<td class="style2"><input type="submit" name="submittable" value="Get Ticket" /></td>
<td> </td>
</tr>
</table>
</form>
<h4>Be sure to add your IP as a Trusted IP address to the server</h4>
</body>
</html>
運行如下:
Username:TableauServer中已添加的用戶
Server:TableauServer的地址
Client IP:受信任主機的IP
Site: 站點名稱 單一站點不填 多站點:輸入站點名稱
點擊Get Ticket 回傳一個24位隨機碼 這就是客戶端的受信任票據資訊
.NET中的應用:
- 獲取票據資訊
Post
/// <summary>
/// 獲取票證
/// </summary>
/// <returns></returns>
public static string getTrustedTicket(string wgserver, string user)
{
var client = new RestClient(wgserver);
client.Timeout = -1;
var request = new RestRequest(Method.POST);
request.AddHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");//請求需要添加的資訊
request.AddParameter("username", user);
IRestResponse response = client.Execute(request);
var ticketServer = response.Content.ToString();
return ticketServer;
}
- 拼接訪問URL
public string getTicketUrl()
{
var configuration = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json").Build();
string tableauServer = configuration["TableauServer"];//TableauServer地址
string Nginx = configuration["Nginx"];//Nginx服務器地址
string TableauReport = configuration["EnergyAndShipping"];//報表后綴
string user = configuration["User"];//Tableau添加的用戶名
string ticket;
string ticketUrl = "";
try
{
ticket = getTrustedTicket(Nginx, user);
if (!ticket.Equals("-1"))
{
ticketUrl = tableauServer + "/" + ticket + "/#" + TableauReport;
}
else
{
return "-1";
}
}
catch (Exception ex)
{
return ("獲取票據資訊失敗!" + ex.Message); ;
}
return ticketUrl;
}
- 前端報表渲染
下載需要的css和js檔案
<link type="text/css" rel="stylesheet" href="https://onlinehelp.tableau.com/samples/en-us/js_api/css/smoothness/jquery-ui-1.10.0.custom.css">
<link type="text/css" rel="stylesheet" href="https://onlinehelp.tableau.com/samples/en-us/js_api/css/Modern.css">
<link type="text/css" rel="stylesheet" href="https://onlinehelp.tableau.com/samples/en-us/js_api/css/tutorial.css">
<script type="text/javascript" src="https://onlinehelp.tableau.com/samples/en-us/js_api/jquery-1.9.1.js"></script>
<script type="text/javascript" src="https://onlinehelp.tableau.com/samples/en-us/js_api/jquery-ui-1.10.0.custom.js"></script>
<script type="text/javascript" src="https://public.tableau.com/javascripts/api/tableau-2.0.0.min.js"></script>
<script type="text/javascript" src="https://onlinehelp.tableau.com/samples/en-us/js_api/tutorial.js"></script>
頁面添加一個div id自定義:例如:tableauViz
Js添加代碼:
initializeViz();//方法呼叫
function initializeViz() {
var placeholderDiv = document.getElementById("tableauViz");
var url = TicketUrl;//后臺回傳的帶有票據資訊的url
var options = {
width: placeholderDiv.offsetWidth,
height: placeholderDiv.offsetHeight,
hideTabs: true,
hideToolbar: true,
onFirstInteractive: function () {
workbook = viz.getWorkbook();
activeSheet = workbook.getActiveSheet();
}
};
viz = new tableau.Viz(placeholderDiv, url, options);
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/ruanti/306101.html
標籤:其他
上一篇:【歷史上的今天】10 月 6 日:互聯網先驅誕生日;蓮花公司宣布上市
下一篇:Mybatis-Plus邏輯洗掉
