-
-
Save vishnoor/92165bd3995f422554351d3fc60663a2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package com.example.controllers.dashboard; | |
import org.springframework.security.jwt.Jwt; | |
import org.springframework.security.jwt.JwtHelper; | |
import org.springframework.security.jwt.crypto.sign.MacSigner; | |
import org.springframework.web.bind.annotation.GetMapping; | |
import org.springframework.web.bind.annotation.RequestMapping; | |
import org.springframework.web.bind.annotation.RestController; | |
@RestController | |
@RequestMapping(value = {"/dashboardUrl"}) | |
public class DashboardController { | |
private final String METABASE_SITE_URL = "http://somehost/metabaseUrl"; | |
private final String METABASE_SECRET_KEY = "SOME_SECRET_KEY"; | |
@GetMapping("") | |
public DashboardParams indexAction() { | |
Jwt token = JwtHelper.encode("{\"resource\": {\"dashboard\": 1}, \"params\": {}}", new MacSigner(METABASE_SECRET_KEY)); | |
String url = METABASE_SITE_URL + "/embed/dashboard/" + token.getEncoded() + "#theme=night&bordered=true&titled=true"; | |
return new DashboardParams(url); | |
} | |
class DashboardParams { | |
private String url; | |
public DashboardParams(String url) { | |
this.url = url; | |
} | |
public String getUrl() { | |
return url; | |
} | |
public void setUrl(String url) { | |
this.url = url; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment