First major release #68
@ -0,0 +1,32 @@
|
|||||||
|
package com.hithomelabs.CFTunnels.Controllers;
|
||||||
|
|
||||||
|
|
||||||
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.GetMapping;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
|
||||||
|
@Controller
|
||||||
|
public class HomeController implements ErrorController {
|
||||||
|
|
||||||
|
private static final String ERROR_PATH = "/error";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Redirects the root (including any query params like ?continue=…)
|
||||||
|
* straight into Swagger UI.
|
||||||
|
*/
|
||||||
|
@GetMapping("/")
|
||||||
|
public String rootRedirect() {
|
||||||
|
return "redirect:/swagger-ui/index.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Catches any errors (404s, unhandled paths) and punts them
|
||||||
|
* into the same Swagger UI page.
|
||||||
|
*/
|
||||||
|
@RequestMapping(ERROR_PATH)
|
||||||
|
public String onError() {
|
||||||
|
return "redirect:/swagger-ui/index.html";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@ -9,6 +9,7 @@ import com.hithomelabs.CFTunnels.Models.Config;
|
|||||||
import com.hithomelabs.CFTunnels.Models.Ingress;
|
import com.hithomelabs.CFTunnels.Models.Ingress;
|
||||||
import com.hithomelabs.CFTunnels.Models.TunnelResponse;
|
import com.hithomelabs.CFTunnels.Models.TunnelResponse;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.boot.web.servlet.error.ErrorController;
|
||||||
import org.springframework.http.*;
|
import org.springframework.http.*;
|
||||||
import org.springframework.security.access.prepost.PreAuthorize;
|
import org.springframework.security.access.prepost.PreAuthorize;
|
||||||
import org.springframework.security.core.GrantedAuthority;
|
import org.springframework.security.core.GrantedAuthority;
|
||||||
@ -23,9 +24,10 @@ import java.util.Map;
|
|||||||
|
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/cloudflare")
|
@RequestMapping("/cloudflare")
|
||||||
public class TunnelController {
|
public class TunnelController implements ErrorController {
|
||||||
|
|
||||||
private final RestTemplate restTemplate = new RestTemplate();
|
private final RestTemplate restTemplate = new RestTemplate();
|
||||||
|
private static final String ERROR_PATH = "/error";
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private AuthoritiesToGroupMapping authoritiesToGroupMapping;
|
private AuthoritiesToGroupMapping authoritiesToGroupMapping;
|
||||||
@ -38,11 +40,6 @@ public class TunnelController {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private RestTemplateConfig restTemplateConfig;
|
private RestTemplateConfig restTemplateConfig;
|
||||||
|
|
||||||
@GetMapping("/")
|
|
||||||
public String redirectToSwagger() {
|
|
||||||
return "redirect:/swagger-ui/index.html";
|
|
||||||
}
|
|
||||||
|
|
||||||
@PreAuthorize("hasAnyRole('USER')")
|
@PreAuthorize("hasAnyRole('USER')")
|
||||||
@GetMapping("/whoami")
|
@GetMapping("/whoami")
|
||||||
public Map<String,Object> whoAmI(@AuthenticationPrincipal OidcUser oidcUser) {
|
public Map<String,Object> whoAmI(@AuthenticationPrincipal OidcUser oidcUser) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user