Skip to content

Commit e3c254e

Browse files
OPENIG-8693 Apply latest IDM Service configuration
1 parent a9d1413 commit e3c254e

File tree

5 files changed

+86
-154
lines changed

5 files changed

+86
-154
lines changed

config/7.3.0/securebanking/ig/config/dev/config/config.json

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -141,43 +141,6 @@
141141
"format": "PLAIN"
142142
}
143143
},
144-
{
145-
"name": "IDMClientHandler",
146-
"type": "Chain",
147-
"config": {
148-
"filters": [
149-
{
150-
"type": "ResourceOwnerOAuth2ClientFilter",
151-
"config": {
152-
"tokenEndpoint": "https://&{identity.platform.fqdn}/am/oauth2/realms/root/realms/&{am.realm}/access_token",
153-
"username": "&{ig.idm.user}",
154-
"passwordSecretId": "ig.idm.password",
155-
"secretsProvider": "SystemAndEnvSecretStore-IAM",
156-
"scopes": [
157-
"fr:idm:*"
158-
],
159-
"endpointHandler": {
160-
"type": "Chain",
161-
"config": {
162-
"handler": "ForgeRockClientHandler",
163-
"filters": [
164-
{
165-
"type": "ClientSecretBasicAuthenticationFilter",
166-
"config": {
167-
"clientId": "&{ig.client.id}",
168-
"clientSecretId": "ig.client.secret",
169-
"secretsProvider": "SystemAndEnvSecretStore-IAM"
170-
}
171-
}
172-
]
173-
}
174-
}
175-
}
176-
}
177-
],
178-
"handler": "ForgeRockClientHandler"
179-
}
180-
},
181144
{
182145
"name": "TrustManager-OB",
183146
"type": "TrustManager",
@@ -234,7 +197,15 @@
234197
"type": "IdmService",
235198
"config": {
236199
"baseEndpoint": "&{urls.idmBaseUri}",
237-
"endpointHandler": "IDMClientHandler"
200+
"tokenEndpoint": "https://&{identity.platform.fqdn}/am/oauth2/realms/root/realms/&{am.realm}/access_token",
201+
"username": "&{ig.idm.user}",
202+
"passwordSecretId": "ig.idm.password",
203+
"secretsProvider": "SystemAndEnvSecretStore-IAM",
204+
"authMethod": "CLIENT_SECRET_BASIC",
205+
"authConfig": {
206+
"clientId": "&{ig.client.id}",
207+
"clientSecretId": "ig.client.secret"
208+
}
238209
}
239210
},
240211
{

config/7.3.0/securebanking/ig/config/prod/config/config.json

Lines changed: 9 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -129,43 +129,6 @@
129129
"format": "PLAIN"
130130
}
131131
},
132-
{
133-
"name": "IDMClientHandler",
134-
"type": "Chain",
135-
"config": {
136-
"filters": [
137-
{
138-
"type": "ResourceOwnerOAuth2ClientFilter",
139-
"config": {
140-
"tokenEndpoint": "https://&{identity.platform.fqdn}/am/oauth2/realms/root/realms/&{am.realm}/access_token",
141-
"username": "&{ig.idm.user}",
142-
"passwordSecretId": "ig.idm.password",
143-
"secretsProvider": "SystemAndEnvSecretStore-IAM",
144-
"scopes": [
145-
"fr:idm:*"
146-
],
147-
"endpointHandler": {
148-
"type": "Chain",
149-
"config": {
150-
"handler": "ForgeRockClientHandler",
151-
"filters": [
152-
{
153-
"type": "ClientSecretBasicAuthenticationFilter",
154-
"config": {
155-
"clientId": "&{ig.client.id}",
156-
"clientSecretId": "ig.client.secret",
157-
"secretsProvider": "SystemAndEnvSecretStore-IAM"
158-
}
159-
}
160-
]
161-
}
162-
}
163-
}
164-
}
165-
],
166-
"handler": "ForgeRockClientHandler"
167-
}
168-
},
169132
{
170133
"name": "TrustManager-OB",
171134
"type": "TrustManager",
@@ -222,7 +185,15 @@
222185
"type": "IdmService",
223186
"config": {
224187
"baseEndpoint": "&{urls.idmBaseUri}",
225-
"endpointHandler": "IDMClientHandler"
188+
"tokenEndpoint": "https://&{identity.platform.fqdn}/am/oauth2/realms/root/realms/&{am.realm}/access_token",
189+
"username": "&{ig.idm.user}",
190+
"passwordSecretId": "ig.idm.password",
191+
"secretsProvider": "SystemAndEnvSecretStore-IAM",
192+
"authMethod": "CLIENT_SECRET_BASIC",
193+
"authConfig": {
194+
"clientId": "&{ig.client.id}",
195+
"clientSecretId": "ig.client.secret"
196+
}
226197
}
227198
},
228199
{

config/7.3.0/securebanking/ig/routes/routes-service/100-internal-repo.json

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,10 @@
2828
"type": "ScriptableHandler",
2929
"config": {
3030
"type": "application/x-groovy",
31-
"clientHandler": "IDMClientHandler",
3231
"file": "RepoApiClient.groovy",
3332
"args": {
34-
"routeArgObjApiClient": "apiClient",
35-
"routeArgIdmBaseUri": "https://&{identity.platform.fqdn}"
33+
"routeArgIdmService": "${heap[IdmService]}",
34+
"routeArgObjApiClient": "apiClient"
3635
}
3736
}
3837
}
@@ -47,7 +46,7 @@
4746
"clientHandler": "IDMClientHandler",
4847
"file": "RepoUser.groovy",
4948
"args": {
50-
"routeArgIdmBaseUri": "https://&{identity.platform.fqdn}",
49+
"routeArgIdmService": "${heap[IdmService]}",
5150
"routeArgObjUser": "&{user.object}"
5251
}
5352
}
Lines changed: 32 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import groovy.json.JsonOutput
2+
import static org.forgerock.util.CloseSilentlyAsyncFunction.closeSilently;
3+
import static org.forgerock.util.promise.NeverThrowsException.neverThrownAsync;
24

35
def fapiInteractionId = request.getHeaders().getFirst("x-fapi-interaction-id");
46
if(fapiInteractionId == null) fapiInteractionId = "No x-fapi-interaction-id";
@@ -28,36 +30,33 @@ def apiClientId = splitUri[splitUri.length - 1];
2830
logger.debug(SCRIPT_NAME + "Looking up API Client {}",apiClientId)
2931

3032
apiClientRequest.setUri(routeArgIdmBaseUri + "/openidm/managed/" + routeArgObjApiClient + "/" + apiClientId)
31-
32-
http.send(apiClientRequest).then(apiClientResponse -> {
33-
apiClientRequest.close()
34-
logger.debug(SCRIPT_NAME + "Back from IDM")
35-
36-
def apiClientResponseStatus = apiClientResponse.getStatus();
37-
38-
if (apiClientResponseStatus != Status.OK) {
39-
message = "Failed to get API Client details"
40-
logger.error(message)
41-
response.status = apiClientResponseStatus
42-
response.entity = "{ \"error\":\"" + message + "\"}"
43-
return response
44-
}
45-
46-
def apiClientResponseContent = apiClientResponse.getEntity();
47-
def apiClientResponseObject = apiClientResponseContent.getJson();
48-
49-
def responseObj = [
50-
"id": apiClientResponseObject.id,
51-
"name": apiClientResponseObject.name,
52-
"officialName": apiClientResponseObject.name,
53-
"oauth2ClientId": apiClientResponseObject.oauth2ClientId,
54-
"logoUri": apiClientResponseObject.logoUri
55-
]
56-
57-
def responseJson = JsonOutput.toJson(responseObj);
58-
logger.debug(SCRIPT_NAME + "Final JSON " + responseJson)
59-
60-
response.entity = responseJson;
61-
return response
62-
63-
}).then(response -> { return response })
33+
idmService.send(context, apiClientRequest)
34+
.thenAsync(closeSilently(response -> {
35+
logger.debug(SCRIPT_NAME + "Back from IDM")
36+
def apiClientResponseStatus = apiClientResponse.getStatus();
37+
38+
if (apiClientResponseStatus != Status.OK) {
39+
message = "Failed to get API Client details"
40+
logger.error(message)
41+
response.status = apiClientResponseStatus
42+
response.entity = "{ \"error\":\"" + message + "\"}"
43+
return response
44+
}
45+
return response.getEntity()
46+
.getJsonAsync()
47+
.then(json -> {
48+
def responseObj = [
49+
"id" : json.id,
50+
"name" : json.name,
51+
"officialName" : json.name,
52+
"oauth2ClientId": json.oauth2ClientId,
53+
"logoUri" : json.logoUri
54+
]
55+
56+
def responseJson = JsonOutput.toJson(responseObj);
57+
logger.debug(SCRIPT_NAME + "Final JSON " + responseJson)
58+
59+
response.entity = responseJson;
60+
return response
61+
});
62+
}), neverThrownAsync())

config/7.3.0/securebanking/ig/scripts/groovy/RepoUser.groovy

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -39,47 +39,39 @@ if(Objects.nonNull(uriQuery)){
3939
- curl -i -v http://ig:80/repo/users?_queryFilter=userName+eq+%22<Cloud platform user name>%22
4040
- curl -i -v http://ig:80/repo/users/<Cloud platform user ID>
4141
*/
42-
43-
http.send(userRequest).then(userResponse -> {
44-
userRequest.close()
45-
logger.debug(SCRIPT_NAME + "Back from IDM")
46-
47-
def userResponseStatus = userResponse.getStatus();
48-
logger.debug(SCRIPT_NAME + " status {}", userResponseStatus)
49-
50-
if (userResponseStatus != Status.OK) {
51-
return errorResponse("User details not found", userResponseStatus)
52-
}
53-
54-
def userResponseContent = userResponse.getEntity()
55-
56-
logger.debug(SCRIPT_NAME + "response JSON {}", userResponseContent.getJson().result)
57-
58-
// build response Object
59-
def userResponseObject = userResponseContent.getJson()
60-
if(queryFilter){
61-
if(userResponseContent.getJson().result.isEmpty()){
62-
return errorResponse("User details not found", Status.NOT_FOUND)
63-
}
64-
userResponseObject = userResponseContent.getJson().result[0]
65-
}
66-
67-
def responseObj = [
68-
"id": userResponseObject._id,
69-
"userName": userResponseObject.userName,
70-
"givenName": userResponseObject.givenName,
71-
"surname": userResponseObject.sn,
72-
"mail": userResponseObject.mail,
73-
"accountStatus": userResponseObject.accountStatus
74-
]
75-
76-
def responseJson = JsonOutput.toJson(responseObj)
77-
logger.debug(SCRIPT_NAME + "Final JSON " + responseJson)
78-
79-
response.entity = responseJson;
80-
return response
81-
82-
}).then(response -> { return response })
42+
idmService.send(context, userRequest)
43+
.thenAsync(closeSilently(response -> {
44+
logger.debug(SCRIPT_NAME + "Back from IDM")
45+
def userResponseStatus = userResponse.getStatus();
46+
logger.debug(SCRIPT_NAME + " status {}", userResponseStatus)
47+
if (userResponseStatus != Status.OK) {
48+
return errorResponse("User details not found", userResponseStatus)
49+
}
50+
return response.getEntity()
51+
.getJsonAsync()
52+
.then(json -> {
53+
if(queryFilter){
54+
if(json.isEmpty()){
55+
return errorResponse("User details not found", Status.NOT_FOUND)
56+
}
57+
userResponseObject = userResponseContent.getJson().result[0]
58+
}
59+
def responseObj = [
60+
"id": json._id,
61+
"userName": json.userName,
62+
"givenName": json.givenName,
63+
"surname": json.sn,
64+
"mail": json.mail,
65+
"accountStatus": json.accountStatus
66+
]
67+
68+
def responseJson = JsonOutput.toJson(responseObj)
69+
logger.debug(SCRIPT_NAME + "Final JSON " + responseJson)
70+
71+
response.entity = responseJson;
72+
return response
73+
});
74+
}), neverThrownAsync())
8375

8476
def errorResponse(String message, userResponseStatus) {
8577
logger.error(SCRIPT_NAME + message)

0 commit comments

Comments
 (0)