Skip to content

Commit 3d67e96

Browse files
committed
Adding support for OBP-OIDC WIP
1 parent ebab6a5 commit 3d67e96

2 files changed

Lines changed: 53 additions & 5 deletions

File tree

src/main/java/com/openbankproject/hydra/auth/controller/IndexController.java

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
import com.openbankproject.hydra.auth.util.PKCEUtil;
1111
import com.openbankproject.model.*;
1212
import org.apache.commons.lang3.ArrayUtils;
13+
import org.apache.commons.lang3.StringUtils;
1314
import org.slf4j.Logger;
1415
import org.slf4j.LoggerFactory;
1516
import org.springframework.beans.factory.annotation.Autowired;
@@ -370,6 +371,15 @@ public String requestConsents(@RequestParam("bank") String bankId,
370371
SessionData.remoteUserInfo(session);
371372

372373
return redirectUrl;
374+
} catch (HttpStatusCodeException httpException) {
375+
logger.error("Error: ", httpException);
376+
String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText();
377+
String responseBody = httpException.getResponseBodyAsString();
378+
if (StringUtils.isNotBlank(responseBody)) {
379+
errorDetail += " - " + responseBody;
380+
}
381+
model.addAttribute("errorMsg", errorDetail);
382+
return "error";
373383
} catch (Exception unhandledException) {
374384
logger.error("Error: ", unhandledException);
375385
if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException);
@@ -619,6 +629,15 @@ public String requestConsentsBerlinGroup(@RequestParam("bank") String bankId,
619629
SessionData.remoteUserInfo(session);
620630

621631
return redirectUrl;
632+
} catch (HttpStatusCodeException httpException) {
633+
logger.error("Error: ", httpException);
634+
String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText();
635+
String responseBody = httpException.getResponseBodyAsString();
636+
if (StringUtils.isNotBlank(responseBody)) {
637+
errorDetail += " - " + responseBody;
638+
}
639+
model.addAttribute("errorMsg", errorDetail);
640+
return "error";
622641
} catch (Exception unhandledException) {
623642
logger.error("Error: ", unhandledException);
624643
if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException);
@@ -738,6 +757,15 @@ public String requestConsentsOpenBankProject(@RequestParam("bank") String bankId
738757
SessionData.remoteUserInfo(session);
739758

740759
return redirectUrl;
760+
} catch (HttpStatusCodeException httpException) {
761+
logger.error("Error: ", httpException);
762+
String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText();
763+
String responseBody = httpException.getResponseBodyAsString();
764+
if (StringUtils.isNotBlank(responseBody)) {
765+
errorDetail += " - " + responseBody;
766+
}
767+
model.addAttribute("errorMsg", errorDetail);
768+
return "error";
741769
} catch (Exception unhandledException) {
742770
logger.error("Error: ", unhandledException);
743771
if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException);
@@ -878,6 +906,15 @@ public String requestConsentsVrpOpenBankProject(@RequestParam("bank") String ban
878906
SessionData.remoteUserInfo(session);
879907

880908
return redirectUrl;
909+
} catch (HttpStatusCodeException httpException) {
910+
logger.error("Error: ", httpException);
911+
String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText();
912+
String responseBody = httpException.getResponseBodyAsString();
913+
if (StringUtils.isNotBlank(responseBody)) {
914+
errorDetail += " - " + responseBody;
915+
}
916+
model.addAttribute("errorMsg", errorDetail);
917+
return "error";
881918
} catch (Exception unhandledException) {
882919
logger.error("Error: ", unhandledException);
883920
if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException);
@@ -943,6 +980,15 @@ public String administrateConsents(@RequestParam("bank") String bankId, HttpSess
943980
SessionData.remoteUserInfo(session);
944981

945982
return redirectUrl;
983+
} catch (HttpStatusCodeException httpException) {
984+
logger.error("Error: ", httpException);
985+
String errorDetail = httpException.getStatusCode() + " " + httpException.getStatusText();
986+
String responseBody = httpException.getResponseBodyAsString();
987+
if (StringUtils.isNotBlank(responseBody)) {
988+
errorDetail += " - " + responseBody;
989+
}
990+
model.addAttribute("errorMsg", errorDetail);
991+
return "error";
946992
} catch (Exception unhandledException) {
947993
logger.error("Error: ", unhandledException);
948994
if(showUnhandledErrors) model.addAttribute("errorMsg", unhandledException);

src/main/resources/application.properties

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,16 +7,18 @@ server.port=52765
77
#logging.level.com.openbankproject=DEBUG
88

99
## OIDC provider: obp-oidc (default) or hydra
10-
#oauth2.provider=hydra
10+
oauth2.provider=obp-oidc
1111

1212
## OBP-OIDC local defaults
1313
oauth2.public_url=http://localhost:9000/obp-oidc
1414
obp.base_url=http://localhost:8080
1515
endpoint.path.prefix=${obp.base_url}/open-banking/v3.1
1616

1717
oauth2.redirect_uri=http://localhost:52765/main.html
18-
oauth2.client_id=your_client_id_here
19-
oauth2.client_secret=your_client_secret_here
18+
19+
# hola | wugxfdiewmkstnzkjlcudeiegddczg41exzirtik | imras3cgsjwplcjdcnmj0abkx1nxqlnbyawvwx3e
20+
oauth2.client_id=wugxfdiewmkstnzkjlcudeiegddczg41exzirtik
21+
oauth2.client_secret=imras3cgsjwplcjdcnmj0abkx1nxqlnbyawvwx3e
2022
oauth2.client_scope=openid,profile,email
2123

2224
## To use Hydra instead, uncomment and adjust:
@@ -51,8 +53,8 @@ display_standards=UKOpenBanking,BerlinGroup,OBP-API,OBP-API-VRP
5153
#button.hover.background_color=#b92c28
5254

5355
### Show internal server errors to the end user
54-
#show_unhandled_errors=false
56+
show_unhandled_errors=true
5557

5658
### Show Bank Logo
5759
#logo.bank.enabled=false
58-
#logo.bank.url=https://static.openbankproject.com/bank/img/bank-logo.png
60+
#logo.bank.url=https://static.openbankproject.com/bank/img/bank-logo.png

0 commit comments

Comments
 (0)