1

偽のGsonを使用するサービスを順番に呼び出すエンドポイントを呼び出すときに、春のセキュリティを使用して春に偽装を実行しています

終点:

 @ApiOperation(value = "Cisco 1000v", notes = "Used with Nexus 1000v to Get configuration")
 @RequestMapping(value = "/cisco", method = RequestMethod.GET)
public String getCisco(
         @ApiParam(value = "Function to apply to switch", required = true)   @RequestParam(value="Function") String function,
         @ApiParam(value = "Hostname of device", required = true) @RequestParam(value="host")  String hostname,
         @ApiParam(value = "Username for device login", required = true) @RequestParam(value="user") String username,
         @ApiParam(value = "Password of device", required = true) @RequestParam(value="pass")   String password) throws IOException, SAXException, ParserConfigurationException {

    CiscoNexus service = new CiscoNexus(hostname, username, password);
    if (function.equals("port-profile")) {
        return service.getPort();`

サービス:

public class CiscoNexus {

private final String hostname, username, password;

public CiscoNexus(String hostname, String username, String password) {
    this.hostname = hostname;
    this.username = username;
    this.password = password;
}
public String getPort() {
    PortProfiles ports = Feign.builder()
            .decoder(new GsonDecoder())
            .encoder(new GsonEncoder())
            .target(PortProfiles.class, "http://" + username + ":" + password + "@" + hostname);

    System.out.println("Getting Port Profiles...");
    ports.get();
    return ports.get();
}

interface PortProfiles {
    @RequestLine("GET /api/port-profile")
    @Headers("Accept: application/json")
    String get();
}

エンドポイントを呼び出すときにスプリングセキュリティを使用しているため、認証ヘッダーを追加する必要がありますが、ヘッダーを保持し、それが原因で正しく応答しないターゲットに送信するように見えます。避けた?

4

0 に答える 0