Skip to content

Commit

Permalink
feat: remove ExchangeTokenService, TokenController and a ProductContr…
Browse files Browse the repository at this point in the history
…oller api
  • Loading branch information
giulia-tremolada committed May 9, 2024
1 parent ff176da commit dc51588
Show file tree
Hide file tree
Showing 9 changed files with 3 additions and 1,840 deletions.
268 changes: 1 addition & 267 deletions app/src/main/resources/swagger/api-docs.json
Original file line number Diff line number Diff line change
Expand Up @@ -1805,98 +1805,6 @@
} ]
}
},
"/v1/products/{productId}/back-office" : {
"get" : {
"tags" : [ "products" ],
"summary" : "retrieveProductBackoffice",
"description" : "Service to trigger token exchange and redirect to product's back office URL",
"operationId" : "retrieveProductBackofficeUsingGET",
"parameters" : [ {
"name" : "productId",
"in" : "path",
"description" : "Product's unique identifier",
"required" : true,
"style" : "simple",
"schema" : {
"type" : "string"
}
}, {
"name" : "institutionId",
"in" : "query",
"description" : "Institution's unique internal identifier",
"required" : true,
"style" : "form",
"schema" : {
"type" : "string"
}
}, {
"name" : "environment",
"in" : "query",
"description" : "Back Office environment",
"required" : false,
"style" : "form",
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"type" : "string",
"format" : "uri"
}
}
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"401" : {
"description" : "Unauthorized",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"404" : {
"description" : "Not Found",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"500" : {
"description" : "Internal Server Error",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
}
},
"security" : [ {
"bearerAuth" : [ "global" ]
} ]
}
},
"/v1/products/{productId}/brokers/{institutionType}" : {
"get" : {
"tags" : [ "products" ],
Expand Down Expand Up @@ -2358,180 +2266,6 @@
} ]
}
},
"/v1/token/exchange" : {
"get" : {
"tags" : [ "token" ],
"summary" : "exchange",
"description" : "Service create an 'Identity Token' based on a Self Care session token",
"operationId" : "exchangeUsingGET",
"parameters" : [ {
"name" : "institutionId",
"in" : "query",
"description" : "Institution's unique internal identifier",
"required" : true,
"style" : "form",
"schema" : {
"type" : "string"
}
}, {
"name" : "productId",
"in" : "query",
"description" : "Product's unique identifier",
"required" : true,
"style" : "form",
"schema" : {
"type" : "string"
}
}, {
"name" : "environment",
"in" : "query",
"description" : "Back Office environment",
"required" : false,
"style" : "form",
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"$ref" : "#/components/schemas/IdentityTokenResource"
}
}
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"401" : {
"description" : "Unauthorized",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"404" : {
"description" : "Not Found",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"500" : {
"description" : "Internal Server Error",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
}
},
"security" : [ {
"bearerAuth" : [ "global" ]
} ]
}
},
"/v1/token/exchange/fatturazione" : {
"get" : {
"tags" : [ "token" ],
"summary" : "billingToken",
"description" : "Service to create a 'Billing Token' based on a Self Care session token",
"operationId" : "billingTokenUsingGET",
"parameters" : [ {
"name" : "institutionId",
"in" : "query",
"description" : "Institution's unique internal identifier",
"required" : true,
"style" : "form",
"schema" : {
"type" : "string"
}
}, {
"name" : "environment",
"in" : "query",
"description" : "Back Office environment",
"required" : false,
"style" : "form",
"schema" : {
"type" : "string"
}
} ],
"responses" : {
"200" : {
"description" : "OK",
"content" : {
"application/json" : {
"schema" : {
"type" : "string",
"format" : "uri"
}
}
}
},
"400" : {
"description" : "Bad Request",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"401" : {
"description" : "Unauthorized",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"404" : {
"description" : "Not Found",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
},
"500" : {
"description" : "Internal Server Error",
"content" : {
"application/problem+json" : {
"schema" : {
"$ref" : "#/components/schemas/Problem"
}
}
}
}
},
"security" : [ {
"bearerAuth" : [ "global" ]
} ]
}
},
"/v2/token/exchange" : {
"get" : {
"tags" : [ "token" ],
Expand Down Expand Up @@ -2628,7 +2362,7 @@
"tags" : [ "token" ],
"summary" : "billingToken",
"description" : "Service to create a 'Billing Token' based on a Self Care session token",
"operationId" : "billingTokenUsingGET_1",
"operationId" : "billingTokenUsingGET",
"parameters" : [ {
"name" : "authenticated",
"in" : "query",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import com.fasterxml.jackson.databind.ObjectMapper;
import it.pagopa.selfcare.dashboard.core.*;
import it.pagopa.selfcare.dashboard.web.model.mapper.*;
import it.pagopa.selfcare.dashboard.web.security.ExchangeTokenService;
import it.pagopa.selfcare.dashboard.web.security.ExchangeTokenServiceV2;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
Expand Down Expand Up @@ -50,9 +49,6 @@ class SwaggerConfigTest {
@MockBean
private ExchangeTokenServiceV2 exchangeTokenServiceV2Mock;

@MockBean
private ExchangeTokenService exchangeTokenServiceMock;

@MockBean
private ProductService productServiceMock;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,23 +7,18 @@
import it.pagopa.selfcare.dashboard.connector.model.backoffice.BrokerInfo;
import it.pagopa.selfcare.dashboard.core.BrokerService;
import it.pagopa.selfcare.dashboard.core.ProductService;
import it.pagopa.selfcare.dashboard.web.model.ExchangedToken;
import it.pagopa.selfcare.dashboard.web.model.mapper.BrokerResourceMapper;
import it.pagopa.selfcare.dashboard.web.model.mapper.ProductsMapper;
import it.pagopa.selfcare.dashboard.web.model.product.BrokerResource;
import it.pagopa.selfcare.dashboard.web.model.product.ProductRoleMappingsResource;
import it.pagopa.selfcare.dashboard.web.security.ExchangeTokenService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.http.MediaType;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.*;

import java.net.URI;
import java.util.Collection;
import java.util.List;
import java.util.Optional;

@Slf4j
@RestController
Expand All @@ -32,18 +27,15 @@
public class ProductController {

private final ProductService productService;
private final ExchangeTokenService exchangeTokenService;
private final BrokerService brokerService;
private final BrokerResourceMapper brokerResourceMapper;
private static final String PAGO_PA_PRODUCT_ID = "prod-pagopa";

@Autowired
public ProductController(ProductService productService,
ExchangeTokenService exchangeTokenService,
BrokerService brokerService,
BrokerResourceMapper brokerResourceMapper) {
this.productService = productService;
this.exchangeTokenService = exchangeTokenService;
this.brokerService = brokerService;
this.brokerResourceMapper = brokerResourceMapper;
}
Expand All @@ -63,28 +55,6 @@ public Collection<ProductRoleMappingsResource> getProductRoles(@ApiParam("${swag
return result;
}

@GetMapping(value = "/{productId}/back-office", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "", notes = "${swagger.dashboard.product.api.retrieveProductBackoffice}")
@PreAuthorize("hasPermission(new it.pagopa.selfcare.dashboard.web.security.ProductAclDomain(#institutionId, #productId), 'ANY')")
public URI retrieveProductBackoffice(@ApiParam("${swagger.dashboard.products.model.id}")
@PathVariable("productId")
String productId,
@ApiParam("${swagger.dashboard.institutions.model.id}")
@RequestParam("institutionId")
String institutionId,
@ApiParam("${swagger.dashboard.product-backoffice-configurations.model.environment}")
@RequestParam(value = "environment", required = false)
Optional<String> environment) {
log.trace("accessProductBackoffice start");
log.debug("accessProductBackoffice institutionId = {}, productId = {}", institutionId, productId);
final ExchangedToken exchangedToken = exchangeTokenService.exchange(institutionId, productId, environment);
final URI location = URI.create(exchangedToken.getBackOfficeUrl().replace("<IdentityToken>", exchangedToken.getIdentityToken()));
log.trace("accessProductBackoffice end");
return location;

}

@GetMapping(value = "/{productId}/brokers/{institutionType}", produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseStatus(HttpStatus.OK)
@ApiOperation(value = "", notes = "${swagger.dashboard.product.api.getProductBrokers}")
Expand Down
Loading

0 comments on commit dc51588

Please sign in to comment.