-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
145 changed files
with
2,483 additions
and
785 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
65 changes: 65 additions & 0 deletions
65
...i-tenant/src/main/java/fr/dossierfacile/api/front/controller/PartnerAccessController.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package fr.dossierfacile.api.front.controller; | ||
|
||
import fr.dossierfacile.api.front.model.tenant.PartnerAccessModel; | ||
import fr.dossierfacile.api.front.security.interfaces.AuthenticationFacade; | ||
import fr.dossierfacile.api.front.service.interfaces.PartnerAccessService; | ||
import fr.dossierfacile.common.entity.Tenant; | ||
import fr.dossierfacile.common.utils.DateBasedFeatureToggle; | ||
import lombok.AllArgsConstructor; | ||
import lombok.extern.slf4j.Slf4j; | ||
import org.springframework.beans.factory.annotation.Value; | ||
import org.springframework.http.MediaType; | ||
import org.springframework.http.ResponseEntity; | ||
import org.springframework.stereotype.Component; | ||
import org.springframework.web.bind.annotation.DeleteMapping; | ||
import org.springframework.web.bind.annotation.GetMapping; | ||
import org.springframework.web.bind.annotation.PathVariable; | ||
import org.springframework.web.bind.annotation.RequestMapping; | ||
import org.springframework.web.bind.annotation.RestController; | ||
|
||
import java.util.List; | ||
|
||
import static org.springframework.http.HttpStatus.FORBIDDEN; | ||
import static org.springframework.http.ResponseEntity.ok; | ||
|
||
@RestController | ||
@AllArgsConstructor | ||
@RequestMapping("/api/tenant/partners") | ||
@Slf4j | ||
public class PartnerAccessController { | ||
|
||
private final AuthenticationFacade authenticationFacade; | ||
private final PartnerAccessService partnerAccessService; | ||
private final PartnerAccessRevocationToggle toggle; | ||
|
||
@GetMapping(produces = MediaType.APPLICATION_JSON_VALUE) | ||
public ResponseEntity<List<PartnerAccessModel>> getPartnerAccesses() { | ||
if (toggle.isNotActive()) { | ||
return ok(List.of()); | ||
} | ||
Tenant tenant = authenticationFacade.getLoggedTenant(); | ||
return ok(partnerAccessService.getExternalPartners(tenant)); | ||
} | ||
|
||
@DeleteMapping("/{id}") | ||
public ResponseEntity<Void> revokePartnerAccess(@PathVariable("id") Long userApiId) { | ||
log.info("Requesting access revocation for partner {}", userApiId); | ||
if (toggle.isNotActive()) { | ||
return ResponseEntity.status(FORBIDDEN).build(); | ||
} | ||
Tenant tenant = authenticationFacade.getLoggedTenant(); | ||
partnerAccessService.deleteAccess(tenant, userApiId); | ||
return ok().build(); | ||
} | ||
|
||
@Component | ||
// TODO delete after activation | ||
static class PartnerAccessRevocationToggle extends DateBasedFeatureToggle { | ||
|
||
public PartnerAccessRevocationToggle(@Value("${toggle.partners.revocation.activation.date:}") String activationDate) { | ||
super(activationDate); | ||
} | ||
|
||
} | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
...acile-api-tenant/src/main/java/fr/dossierfacile/api/front/mapper/PartnerAccessMapper.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package fr.dossierfacile.api.front.mapper; | ||
|
||
import fr.dossierfacile.api.front.model.tenant.PartnerAccessModel; | ||
import fr.dossierfacile.common.entity.TenantUserApi; | ||
import org.mapstruct.Mapper; | ||
import org.mapstruct.Mapping; | ||
import org.springframework.stereotype.Component; | ||
|
||
@Component | ||
@Mapper(componentModel = "spring") | ||
public interface PartnerAccessMapper { | ||
|
||
@Mapping(source = "userApi.id", target = "id") | ||
@Mapping(source = "userApi.name2", target = "name") | ||
@Mapping(source = "userApi.logoUrl", target = "logoUrl") | ||
PartnerAccessModel toModel(TenantUserApi tenantUserApi); | ||
|
||
} |
23 changes: 23 additions & 0 deletions
23
...-api-tenant/src/main/java/fr/dossierfacile/api/front/model/tenant/PartnerAccessModel.java
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package fr.dossierfacile.api.front.model.tenant; | ||
|
||
import com.fasterxml.jackson.annotation.JsonInclude; | ||
import lombok.AllArgsConstructor; | ||
import lombok.Builder; | ||
import lombok.Data; | ||
import lombok.NoArgsConstructor; | ||
|
||
import java.time.LocalDate; | ||
|
||
@Data | ||
@Builder | ||
@NoArgsConstructor | ||
@AllArgsConstructor | ||
@JsonInclude(JsonInclude.Include.NON_NULL) | ||
public class PartnerAccessModel { | ||
|
||
private Long id; | ||
private String name; | ||
private String logoUrl; | ||
private LocalDate accessGrantedDate; | ||
|
||
} |
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
This file contains 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
Oops, something went wrong.