Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bugfix/handle oauth consent #1256

Merged
merged 20 commits into from
May 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,10 @@ public static class CmsEncryption implements EncryptionService {
@Override
@SneakyThrows
public byte[] encrypt(byte[] data) {
if (null == data) {
return new byte[0];
}

CMSEnvelopedDataGenerator generator = new CMSEnvelopedDataGenerator();
generator.addRecipientInfoGenerator(new JceKeyTransRecipientInfoGenerator(encryptionKeyId.getBytes(StandardCharsets.UTF_8), publicKey));
return generator.generate(
Expand All @@ -72,6 +76,10 @@ public byte[] encrypt(byte[] data) {
@Override
@SneakyThrows
public byte[] decrypt(byte[] data) {
if (null == data || 0 == data.length) {
return null;
}

CMSEnvelopedDataParser parser = new CMSEnvelopedDataParser(data);
return parser.getRecipientInfos().iterator().next().getContent(new JceKeyTransEnvelopedRecipient(privateKey));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ paths:
security:
- sessionCookie: []

/v1/consent/{auth-id}/fromAspsp/{redirectState}/ok:
/v1/consent/{auth-id}/fromAspsp/{redirectState}/ok/{fromAspspRedirectCode}:
get:
operationId: fromAspspOkUsingGET
tags:
Expand Down Expand Up @@ -215,8 +215,8 @@ paths:
#path
- $ref: "#/components/parameters/auth-id"
- $ref: "#/components/parameters/redirectState"
- $ref: "#/components/parameters/fromAspspRedirectCode"
#query
- $ref: "#/components/parameters/redirectCode"
- $ref: "#/components/parameters/code"
responses:
"200":
Expand All @@ -226,7 +226,7 @@ paths:
security:
- redirectCookie: []

/v1/consent/{auth-id}/fromAspsp/{redirectState}/nok:
/v1/consent/{auth-id}/fromAspsp/{redirectState}/nok/{fromAspspRedirectCode}:
get:
operationId: fromAspspNokUsingGET
tags:
Expand All @@ -239,8 +239,7 @@ paths:
#path
- $ref: "#/components/parameters/auth-id"
- $ref: "#/components/parameters/redirectState"
#query
- $ref: "#/components/parameters/redirectCode"
- $ref: "#/components/parameters/fromAspspRedirectCode"
responses:
"200":
$ref: "#/components/responses/200_AuthorizeResponse"
Expand Down Expand Up @@ -353,7 +352,17 @@ components:
name: redirectCode
in: query
description: Code used to retrieve a redirect session. This is
generaly transported as a query parameter
generaly transported as a query parameter.
example: "faadsf93nlas32wx"
schema:
type: string

fromAspspRedirectCode:
name: fromAspspRedirectCode
in: path
description: Code used to retrieve a redirect session. This is
generaly transported as a path parameter due to some banks limitiations (ING ASPSP) instead of
being transported as query parameter
example: "faadsf93nlas32wx"
schema:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@ public class FromAspspConsentServiceController implements FromAspspConsentAuthor
public CompletableFuture fromAspspOkUsingGET(
String authId,
String redirectState,
String redirectCode,
String fromAspspRedirectCode,
String code) {

return fromAspspRedirectHandler.execute(
FromAspspRequest.builder()
.facadeServiceable(serviceableTemplate.toBuilder()
.redirectCode(redirectCode)
.redirectCode(fromAspspRedirectCode)
.authorizationSessionId(authId)
.build()
)
Expand All @@ -42,12 +42,12 @@ public CompletableFuture fromAspspOkUsingGET(
public CompletableFuture fromAspspNokUsingGET(
String authId,
String redirectState,
String redirectCode) {
String fromAspspRedirectCode) {

return fromAspspRedirectHandler.execute(
FromAspspRequest.builder()
.facadeServiceable(serviceableTemplate.toBuilder()
.redirectCode(redirectCode)
.redirectCode(fromAspspRedirectCode)
.authorizationSessionId(authId)
.build()
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,11 +84,17 @@ public void setContext(EncryptionService encryption, String context) {
}

public String getConsentId(EncryptionService encryption) {
return new String(encryption.decrypt(encConsentId), StandardCharsets.UTF_8);
byte[] decryptedConsent = encryption.decrypt(encConsentId);
if (null == decryptedConsent) {
return null;
}

return new String(decryptedConsent, StandardCharsets.UTF_8);
}

public void setConsentId(EncryptionService encryption, String consent) {
this.encConsentId = encryption.encrypt(consent.getBytes(StandardCharsets.UTF_8));
byte[] consentToEncrypt = null == consent ? null : consent.getBytes(StandardCharsets.UTF_8);
this.encConsentId = encryption.encrypt(consentToEncrypt);
}
}

12 changes: 6 additions & 6 deletions opba-embedded-starter/src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -219,8 +219,8 @@ protocol:
common:
to-aspsp: /{authSessionId}/to-aspsp-redirection?redirectCode={redirectCode}
web-hooks:
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
result: /{authSessionId}/consent-result?redirectCode={redirectCode}
parameters:
provide-more: /{authSessionId}?redirectCode={redirectCode}
Expand Down Expand Up @@ -254,8 +254,8 @@ protocol:
redirect:
to-aspsp: ${facade.urls.embedded-ui-base-url}/ais/{authSessionId}/to-aspsp-redirection
web-hooks:
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
result: ${facade.urls.embedded-ui-base-url}/ais/{authSessionId}/consent-result?redirectCode={redirectCode}
parameters:
max-array-size: 32
Expand All @@ -268,8 +268,8 @@ protocol:
redirect:
to-aspsp: ${facade.urls.embedded-ui-base-url}/pis/{authSessionId}/to-aspsp-redirection
web-hooks:
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
result: ${facade.urls.embedded-ui-base-url}/pis/{authSessionId}/consent-result?redirectCode={redirectCode}
parameters:
max-array-size: 32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,12 @@ protocol:
urls:
ais:
web-hooks:
ok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
pis:
web-hooks:
ok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}

# FinTech request signing section:
security:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@ protocol:
common:
to-aspsp: /{authSessionId}/to-aspsp-redirection?redirectCode={redirectCode}
web-hooks:
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
result: /{authSessionId}/consent-result?redirectCode={redirectCode}
parameters:
provide-more: /{authSessionId}?redirectCode={redirectCode}
Expand Down Expand Up @@ -245,8 +245,8 @@ protocol:
redirect:
to-aspsp: ${facade.urls.embedded-ui-base-url}/ais/{authSessionId}/to-aspsp-redirection
web-hooks:
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
result: ${facade.urls.embedded-ui-base-url}/ais/{authSessionId}/consent-result?redirectCode={redirectCode}
parameters:
max-array-size: 32
Expand All @@ -259,8 +259,8 @@ protocol:
redirect:
to-aspsp: ${facade.urls.embedded-ui-base-url}/pis/{authSessionId}/to-aspsp-redirection
web-hooks:
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${facade.urls.embedded-ui-base-url}/embedded-server/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
result: ${facade.urls.embedded-ui-base-url}/pis/{authSessionId}/consent-result?redirectCode={redirectCode}
parameters:
max-array-size: 32
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ public SELF open_banking_redirect_from_aspsp_with_static_oauth2_code_to_exchange
.given()
.cookie(AUTHORIZATION_SESSION_KEY, authSessionCookie)
.when()
.get(redirectOkUri + "&code=" + code)
.get(redirectOkUri + "?code=" + code)
.then()
.statusCode(HttpStatus.SEE_OTHER.value())
.extract();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public SELF open_banking_redirect_from_aspsp_with_static_oauth2_code_to_exchange
.given()
.cookie(AUTHORIZATION_SESSION_KEY, authSessionCookie)
.when()
.get(redirectOkUri + "&code=" + code)
.get(redirectOkUri + "?code=" + code)
.then()
.statusCode(HttpStatus.SEE_OTHER.value())
.extract();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@ protocol:
urls:
ais:
web-hooks:
ok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
pis:
web-hooks:
ok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok?redirectCode={aspspRedirectCode}
nok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok?redirectCode={aspspRedirectCode}
ok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/ok/{aspspRedirectCode}
nok: ${protocol.gateway-base-url}/v1/consent/{authSessionId}/fromAspsp/STUB_STATE/nok/{aspspRedirectCode}
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"equalTo": "application/json; charset=UTF-8"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/ok\\?.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/ok/.+"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/nok\\?.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/nok/.+"
}
},
"bodyPatterns": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"equalTo": "application/json; charset=UTF-8"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/ok\\?.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/ok/.+"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/nok\\?.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/nok/.+"
}
},
"bodyPatterns": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"equalTo": "application/json; charset=UTF-8"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/ok\\?.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/ok/.+"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/nok\\?.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/nok/.+"
}
},
"bodyPatterns": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,10 @@
"equalTo": "application/json; charset=UTF-8"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/ok\\?.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/ok/.+"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/nok\\?.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/.+/nok/.+"
}
},
"bodyPatterns": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
"equalTo": "anton.brueckner"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok/.+"
},
"PSU-IP-Address": {
"matches": "\\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}\\b"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok/.+"
},
"Content-Type": {
"equalTo": "application/json; charset=UTF-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
"equalTo": "anton.brueckner"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok/.+"
},
"PSU-IP-Address": {
"matches": "\\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}\\b"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok/.+"
},
"Content-Type": {
"equalTo": "application/json; charset=UTF-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,13 @@
"equalTo": "anton.brueckner"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok/.+"
},
"PSU-IP-Address": {
"matches": "\\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}\\b"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok/.+"
},
"Content-Type": {
"equalTo": "application/json; charset=UTF-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@
"equalTo": "Bearer eyJraWQiOiJFWmtfUDNHd1I2OG9iUEwzSGxDbng0IiwiYWxnIjoiSFMyNTYifQ.eyJzdWIiOiJkMGF1dUlxN1J6QXR6dkNEVDh6bV9vIiwidG9rZW5fdXNhZ2UiOiJMT0dJTiIsInJvbGUiOiJDVVNUT01FUiIsInNjYV9pZCI6Im12RU5SbE5pU3NjcXJuWVNqdnZnYlUiLCJhdXRob3Jpc2F0aW9uX2lkIjoibXZFTlJsTmlTc2Nxcm5ZU2p2dmdiVSIsImV4cCI6MTU5OTY1Mzk5NywibG9naW4iOiJhbnRvbi5icnVlY2tuZXIiLCJpYXQiOjE1OTk2NTM2OTcsImp0aSI6ImdMeVZoZlVLUmdRaU9vbmpaMzVqakkifQ.d3A5uBRFkDcpY8IvYHf3niiDA_BmDgp5aIuoaT2t4xE"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok/.+"
},
"PSU-IP-Address": {
"matches": "\\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}\\b"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok/.+"
},
"Content-Type": {
"equalTo": "application/json; charset=UTF-8"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,13 @@
"equalTo": "anton.brueckner"
},
"TPP-Nok-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/nok/.+"
},
"PSU-IP-Address": {
"matches": "\\b((25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)(\\.|$)){4}\\b"
},
"TPP-Redirect-URI": {
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok\\?redirectCode=.+"
"matches": "http://localhost:\\d+/v1/consent/.+/fromAspsp/STUB_STATE/ok/.+"
},
"Content-Type": {
"equalTo": "application/json; charset=UTF-8"
Expand Down