Skip to content

Commit

Permalink
Merge pull request #1214 from adorsys/bugfix/tpp-declined-consent
Browse files Browse the repository at this point in the history
Bugfix/tpp declined consent
  • Loading branch information
valb3r authored Apr 27, 2021
2 parents c124867 + ab946d7 commit 69e6f82
Show file tree
Hide file tree
Showing 38 changed files with 1,060 additions and 323 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -418,6 +418,31 @@ paths:
"401":
$ref: "#/components/responses/401_Unauthorized"

/v1/ais/banks/{bank-id}/consents:
delete:
tags:
- FinTechAccountInformation
operationId: aisConsentsDELETE
summary: Deletes all consents that are associated with bank
description: Deletes all consents that are associated with bank
parameters:
#path
- $ref: "#/components/parameters/bank-id"

#header
- $ref: "#/components/parameters/X-Request-ID"
- $ref: "#/components/parameters/X-XSRF-TOKEN"

security:
- sessionCookie: [ ]
responses:
"200":
$ref: "#/components/responses/200_ConsentRemovalResult"
"401":
$ref: "#/components/responses/401_Unauthorized"
"404":
$ref: "#/components/responses/404_NotFound"

/v1/consent/{userid}/{password}:
get:
summary: ask for existing consent of user
Expand Down Expand Up @@ -958,6 +983,13 @@ components:
schema:
type: object

200_ConsentRemovalResult:
description: List of all removed consents
content:
application/json:
schema:
type: object

schemas:
paymentInitiationWithStatusResponse:
description: response from open banking gateway
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import de.adorsys.opba.fintech.impl.controller.utils.LoTRetrievalInformation;
import de.adorsys.opba.fintech.impl.database.entities.SessionEntity;
import de.adorsys.opba.fintech.impl.service.AccountService;
import de.adorsys.opba.fintech.impl.service.ConsentService;
import de.adorsys.opba.fintech.impl.service.SessionLogicService;
import de.adorsys.opba.fintech.impl.service.TransactionService;
import lombok.RequiredArgsConstructor;
Expand All @@ -16,6 +17,7 @@
import org.springframework.web.bind.annotation.RestController;

import java.time.LocalDate;
import java.util.Map;
import java.util.UUID;

@Slf4j
Expand All @@ -26,6 +28,7 @@ public class FinTechAccountInformationImpl implements FinTechAccountInformationA
private final SessionLogicService sessionLogicService;
private final AccountService accountService;
private final TransactionService transactionService;
private final ConsentService consentService;

@Override
public ResponseEntity<AccountList> aisAccountsGET(String bankId, UUID xRequestID, String xsrfToken,
Expand Down Expand Up @@ -56,4 +59,11 @@ public ResponseEntity<TransactionsResponse> aisTransactionsGET(String bankId, St
transactionService.listTransactions(sessionEntity, fintechRedirectURLOK, fintechRedirectURLNOK,
bankId, accountId, dateFrom, dateTo, entryReferenceFrom, bookingStatus, deltaList, LoTRetrievalInformation.valueOf(loTRetrievalInformation), online));
}

@Override
public ResponseEntity<Object> aisConsentsDELETE(String bankId, UUID xRequestID, String xsrfToken) {
SessionEntity sessionEntity = sessionLogicService.getSession();
consentService.deleteAllConsentsOfBank(sessionEntity, bankId);
return ResponseEntity.ok().body(Map.of());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import de.adorsys.opba.fintech.impl.database.entities.ConsentEntity;
import de.adorsys.opba.fintech.impl.database.entities.UserEntity;
import de.adorsys.opba.fintech.impl.tppclients.ConsentType;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.repository.CrudRepository;

import java.util.List;
Expand All @@ -18,4 +19,7 @@ List<ConsentEntity> findListByUserEntityAndBankIdAndConsentTypeAndConsentConfirm
bankId, ConsentType consentType, Boolean consentConfirmed);

List<ConsentEntity> findByUserEntityAndConsentTypeAndConsentConfirmedOrderByCreationTimeDesc(UserEntity userEntity, ConsentType consentType, Boolean consentConfirmed);

@Modifying
long deleteByUserEntityAndBankId(UserEntity entity, String bankId);
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package de.adorsys.opba.fintech.impl.service;

import de.adorsys.opba.fintech.impl.database.entities.SessionEntity;
import de.adorsys.opba.fintech.impl.database.repositories.ConsentRepository;
import de.adorsys.opba.fintech.impl.properties.TppProperties;
import de.adorsys.opba.fintech.impl.tppclients.TppConsentClient;
Expand All @@ -9,6 +10,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.UUID;

import static de.adorsys.opba.fintech.impl.tppclients.Consts.COMPUTE_FINTECH_ID;
Expand Down Expand Up @@ -50,4 +52,9 @@ public boolean confirmPayment(String authId, UUID xRequestId) {
log.debug("consent confirmation response code: {}", statusCode);
return statusCode.is2xxSuccessful();
}

@Transactional
public void deleteAllConsentsOfBank(SessionEntity sessionEntity, String bankId) {
consentRepository.deleteByUserEntityAndBankId(sessionEntity.getUserEntity(), bankId);
}
}
2 changes: 1 addition & 1 deletion fintech-examples/fintech-ui/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"version": "0.0.0",
"scripts": {
"ng": "ng",
"openapi-gen": "openapi-generator generate -g typescript-angular -o src/app/api -i ../fintech-api/src/main/resources/static/fintech_api.yml",
"openapi-gen": "openapi-generator generate -g typescript-angular -o src/app/api -i ../fintech-api/src/main/resources/static/fintech_api.yml --skip-validate-spec",
"start": "npm run serve",
"serve": "ng serve --port=4444 --proxy-config=proxy.conf.json",
"serve:dev": "ng serve --port=4444 --proxy-config=proxy-conf-dev-backend.js",
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
4.2.2
4.3.1
25 changes: 25 additions & 0 deletions fintech-examples/fintech-ui/src/app/api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,31 @@ export function apiConfigFactory (): Configuration => {
export class AppModule {}
```

```
// configuring providers with an authentication service that manages your access tokens
import { ApiModule, Configuration } from '';
@NgModule({
imports: [ ApiModule ],
declarations: [ AppComponent ],
providers: [
{
provide: Configuration,
useFactory: (authService: AuthService) => new Configuration(
{
basePath: environment.apiUrl,
accessToken: authService.getAccessToken.bind(authService)
}
),
deps: [AuthService],
multi: false
}
],
bootstrap: [ AppComponent ]
})
export class AppModule {}
```

```
import { DefaultApi } from '';
Expand Down
11 changes: 3 additions & 8 deletions fintech-examples/fintech-ui/src/app/api/api.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,22 +8,17 @@ import { FinTechAuthorizationService } from './api/finTechAuthorization.service'
import { FinTechBankSearchService } from './api/finTechBankSearch.service';
import { FinTechOauth2AuthenticationService } from './api/finTechOauth2Authentication.service';
import { FintechRetrieveAllSinglePaymentsService } from './api/fintechRetrieveAllSinglePayments.service';
import { FintechRetrieveConsentService } from './api/fintechRetrieveConsent.service';
import { FintechSinglePaymentInitiationService } from './api/fintechSinglePaymentInitiation.service';

@NgModule({
imports: [],
declarations: [],
exports: [],
providers: [
FinTechAccountInformationService,
FinTechAuthorizationService,
FinTechBankSearchService,
FinTechOauth2AuthenticationService,
FintechRetrieveAllSinglePaymentsService,
FintechSinglePaymentInitiationService ]
providers: []
})
export class ApiModule {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders {
public static forRoot(configurationFactory: () => Configuration): ModuleWithProviders<ApiModule> {
return {
ngModule: ApiModule,
providers: [ { provide: Configuration, useFactory: configurationFactory } ]
Expand Down
4 changes: 3 additions & 1 deletion fintech-examples/fintech-ui/src/app/api/api/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ export * from './finTechOauth2Authentication.service';
import { FinTechOauth2AuthenticationService } from './finTechOauth2Authentication.service';
export * from './fintechRetrieveAllSinglePayments.service';
import { FintechRetrieveAllSinglePaymentsService } from './fintechRetrieveAllSinglePayments.service';
export * from './fintechRetrieveConsent.service';
import { FintechRetrieveConsentService } from './fintechRetrieveConsent.service';
export * from './fintechSinglePaymentInitiation.service';
import { FintechSinglePaymentInitiationService } from './fintechSinglePaymentInitiation.service';
export const APIS = [FinTechAccountInformationService, FinTechAuthorizationService, FinTechBankSearchService, FinTechOauth2AuthenticationService, FintechRetrieveAllSinglePaymentsService, FintechSinglePaymentInitiationService];
export const APIS = [FinTechAccountInformationService, FinTechAuthorizationService, FinTechBankSearchService, FinTechOauth2AuthenticationService, FintechRetrieveAllSinglePaymentsService, FintechRetrieveConsentService, FintechSinglePaymentInitiationService];
Loading

0 comments on commit 69e6f82

Please sign in to comment.