Skip to content

Commit 5b38cf8

Browse files
authored
Merge pull request #6 from hongwei1/develop
UK Open Banking v4.0.1 consent flow
2 parents 52430b7 + 4ee6aa8 commit 5b38cf8

16 files changed

Lines changed: 499 additions & 309 deletions

application properties.example

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
11
server.port=8087
2-
oauth2.public_url=https://oauth2.openbankproject.com/hydra-public
2+
oauth2.public_url=https://oauth2.openbankproject.com/obp-oidc
33
obp.base_url=https://apisandbox.openbankproject.com
44
endpoint.path.prefix=${obp.base_url}/open-banking/v3.1
5+
endpoint.path.prefix.v401=${obp.base_url}/open-banking/v4.0.1/aisp
56

67
logging.level.com.openbankproject=DEBUG
78

@@ -22,6 +23,7 @@ logo.bank.url=https://static.openbankproject.com/images/obp_logo.png
2223
### insert oauth2-related keys from API consumer registration below ###
2324

2425
oauth2.client_id=taewei3sidooshoaquaisie2ohng8seepieLahna
26+
oauth2.client_secret=imras3cgsjwplcjdcnmj0abkx1nxqlnbyawvwx3e
2527
oauth2.redirect_uri=https://hola.openbankproject.com/main.html
2628
oauth2.client_scope=ReadAccountsBasic,\
2729
ReadAccountsDetail,\
@@ -32,7 +34,3 @@ ReadTransactionsDetail,\
3234
ReadAccountsBerlinGroup,\
3335
ReadBalancesBerlinGroup,\
3436
ReadTransactionsBerlinGroup
35-
36-
oauth2.jws_alg=ES256
37-
oauth2.jwk_private_key={"kty":"EC","d":"Aepaewaibisoo8deevae1Zaeni2ahwee6ne3Aik0ahX","use":"sig","crv":"P-256","kid":"39087g94-2b67-1ab4-124e-157ae7f2c078","x":"b9HEBe415JME8W_rPwAq1Ume_tBbohy2XSXda9Mqoe4","y":"ieSahSh2cheereeF0zix4EeB-kohx9Ieb6mah8obeid","alg":"ES256"}
38-

application.properties.docker

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
server.port=${SERVER_PORT}
2-
oauth2.provider=${OAUTH2_PROVIDER:obp-oidc}
32
oauth2.public_url=${OAUTH_2_PUBLIC_URL}
43
obp.base_url=${OBP_BASE_URL}
54
endpoint.path.prefix=${OBP_BASE_URL}/open-banking/v3.1
5+
endpoint.path.prefix.v401=${OBP_BASE_URL}/open-banking/v4.0.1/aisp
66

77
mtls.keyStore.path=file:///keystore/keystore.jks
88
mtls.keyStore.password=${KEYSTORE_PASSWD}
@@ -21,8 +21,6 @@ oauth2.client_secret=$(OAUTH2_CLIENT_SECRET)
2121
oauth2.client_id=${OAUTH2_CLIENT_ID}
2222
oauth2.redirect_uri=${OAUTH2_REDIRECT_URI}
2323
oauth2.client_scope=${OAUTH2_CLIENT_SCOPE}
24-
#oauth2.jws_alg=${OAUTH2_JWS_ALG}
25-
#oauth2.jwk_private_key=${OAUTH2_JWK_PRIVATE_KEY}
2624

2725
spring.redis.database=${SPRING_REDIS_DATABASE:}
2826
spring.redis.host=${SPRING_REDIS_HOST}

src/main/java/com/openbankproject/hydra/auth/HydraConfig.java

Lines changed: 0 additions & 172 deletions
This file was deleted.

src/main/java/com/openbankproject/hydra/auth/OIDCProvider.java

Lines changed: 0 additions & 25 deletions
This file was deleted.

src/main/java/com/openbankproject/hydra/auth/ObpOidcConfig.java

Lines changed: 1 addition & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,15 @@
44
import org.slf4j.Logger;
55
import org.slf4j.LoggerFactory;
66
import org.springframework.beans.factory.annotation.Value;
7-
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
87
import org.springframework.context.annotation.Bean;
98
import org.springframework.context.annotation.Configuration;
109
import org.springframework.web.client.RestTemplate;
1110

1211
import javax.annotation.PostConstruct;
1312
import javax.annotation.Resource;
14-
import java.util.Map;
1513

1614
@Configuration
17-
@ConditionalOnProperty(name = "oauth2.provider", havingValue = "obp-oidc", matchIfMissing = true)
18-
public class ObpOidcConfig implements OIDCProvider {
15+
public class ObpOidcConfig {
1916
Logger log = LoggerFactory.getLogger(ObpOidcConfig.class);
2017

2118
@Value("${oauth2.public_url:http://localhost:9000/obp-oidc}/.well-known/openid-configuration")
@@ -36,22 +33,4 @@ private void initiate() {
3633
public WellKnown openIDConfiguration() {
3734
return this.openIDConfiguration;
3835
}
39-
40-
/**
41-
* OBP-OIDC uses client_secret authentication, not private_key_jwt.
42-
*/
43-
@Override
44-
public boolean isPublicClient() {
45-
return false;
46-
}
47-
48-
@Override
49-
public String buildClientAssertion() {
50-
throw new UnsupportedOperationException("OBP-OIDC does not support private_key_jwt client assertions");
51-
}
52-
53-
@Override
54-
public String buildRequestObject(Map<String, String> queryParam) {
55-
throw new UnsupportedOperationException("OBP-OIDC does not support signed request objects");
56-
}
5736
}
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
package com.openbankproject.hydra.auth.controller;
2+
3+
import org.slf4j.Logger;
4+
import org.slf4j.LoggerFactory;
5+
import org.springframework.beans.factory.annotation.Value;
6+
import org.springframework.ui.Model;
7+
import org.springframework.web.bind.MissingServletRequestParameterException;
8+
import org.springframework.web.bind.UnsatisfiedServletRequestParameterException;
9+
import org.springframework.web.bind.annotation.ControllerAdvice;
10+
import org.springframework.web.bind.annotation.ExceptionHandler;
11+
12+
/**
13+
* Without this, a request that fails Spring's @PostMapping(params=...) matching
14+
* (e.g. a consent form submitted with no permission checkbox selected) never reaches
15+
* a controller method, so none of the per-endpoint try/catch blocks in IndexController
16+
* run. It falls through to the default error view with a blank message instead.
17+
*/
18+
@ControllerAdvice
19+
public class GlobalExceptionHandler {
20+
private static final Logger logger = LoggerFactory.getLogger(GlobalExceptionHandler.class);
21+
22+
@Value("${obp.base_url:#}")
23+
private String obpBaseUrl;
24+
@Value("${logo.bank.enabled:false}")
25+
private String showBankLogo;
26+
@Value("${logo.bank.url:#}")
27+
private String bankLogoUrl;
28+
@Value("${show_unhandled_errors:false}")
29+
private boolean showUnhandledErrors;
30+
31+
@ExceptionHandler(UnsatisfiedServletRequestParameterException.class)
32+
public String handleUnsatisfiedServletRequestParameter(UnsatisfiedServletRequestParameterException e, Model model) {
33+
logger.warn("Form submission rejected: {}", e.getMessage());
34+
addCommonAttributes(model);
35+
model.addAttribute("errorMsg", "The form is missing one or more required fields (" + e.getMessage()
36+
+ "). If this form has permission checkboxes, make sure at least one is selected before submitting.");
37+
return "error";
38+
}
39+
40+
@ExceptionHandler(MissingServletRequestParameterException.class)
41+
public String handleMissingServletRequestParameter(MissingServletRequestParameterException e, Model model) {
42+
logger.warn("Form submission rejected: {}", e.getMessage());
43+
addCommonAttributes(model);
44+
model.addAttribute("errorMsg", "The form is missing a required field: " + e.getParameterName() + ".");
45+
return "error";
46+
}
47+
48+
// Catches anything a controller method itself doesn't try/catch (this class's other handlers
49+
// above take precedence for their specific exception types). Same showUnhandledErrors
50+
// convention IndexController's own per-endpoint catch-all blocks use.
51+
@ExceptionHandler(Exception.class)
52+
public String handleUnhandled(Exception e, Model model) {
53+
logger.error("Unhandled exception reached GlobalExceptionHandler", e);
54+
addCommonAttributes(model);
55+
model.addAttribute("errorMsg", showUnhandledErrors ? e.toString() : "Internal Server Error");
56+
return "error";
57+
}
58+
59+
private void addCommonAttributes(Model model) {
60+
model.addAttribute("obpBaseUrl", obpBaseUrl);
61+
model.addAttribute("showBankLogo", showBankLogo);
62+
model.addAttribute("bankLogoUrl", bankLogoUrl);
63+
}
64+
}

0 commit comments

Comments
 (0)