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

Fix consent manager issues #165

Merged
merged 14 commits into from
Nov 12, 2024
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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public class RoleClaimProviderImpl implements ClaimProvider {
private static final String USER_ROLE = "user_role";
private static final String OPENID_SCOPE = "openid";
private static final String CUSTOMER_CARE_OFFICER = "customerCareOfficer";
private static final String CUSTOMER_CARE_OFFICER_ROLE = "Internal/CustomerCareOfficerRole";
private static final String INTERNAL_CUSTOMER_CARE_OFFICER_ROLE = "Internal/CustomerCareOfficerRole";
private static final String INTERNAL_CUSTOMER_CARE_OFFICER = "Internal/CustomerCareOfficer";
private static final String CUSTOMER_CARE_OFFICER_SCOPE = "consents:read_all";

@Generated(message = "Do not contain logics")
Expand Down Expand Up @@ -86,7 +87,8 @@ public Map<String, Object> getAdditionalClaims(OAuthTokenReqMessageContext oAuth
UserStoreManager userStoreManager = realmService.getTenantUserRealm(tenantId).getUserStoreManager();

String[] roles = userStoreManager.getRoleListOfUser(userId);
if (ArrayUtils.contains(roles, CUSTOMER_CARE_OFFICER_ROLE)) {
if (ArrayUtils.contains(roles, INTERNAL_CUSTOMER_CARE_OFFICER_ROLE) || ArrayUtils.contains(roles,
INTERNAL_CUSTOMER_CARE_OFFICER)) {
claims.put(USER_ROLE, CUSTOMER_CARE_OFFICER);
}
} catch (IdentityRuntimeException e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -367,7 +367,10 @@ public boolean revokeConsentWithReason(String consentID, String revokedConsentSt
" is not a member of the consent user list");
throw new ConsentManagementException(errorMsg);
}
revokeTokens(retrievedDetailedConsentResource, userID);

for (String user : consentUserIDSet) {
revokeTokens(retrievedDetailedConsentResource, user);
}
}

ArrayList<ConsentMappingResource> consentMappingResources = retrievedDetailedConsentResource
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ export const Footer = () => {
return(
<Container className = "Footer">
<Col className = "footerCol">
<Row className = "footerText"><a href = "#" className = "complaintText">{common.complaintHandleLinkText}</a></Row>
<Row className = "footerText">{common.footerContent}</Row>
</Col>
</Container>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,10 @@ export const Nav = (user) => {
className="navUserImage"
rounded
/>
<span className="dropdown-userId">{user.email}</span>
<span className="dropdown-userId">{
(user.email && user.email.indexOf("@" + CONFIG.TENANT_DOMAIN) !== -1) ?
user.email.replace("@" + CONFIG.TENANT_DOMAIN, "") : user.email
}</span>
</span>
}
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,15 @@ export const KeyDatesInfo = ({consent, infoLabels, consentType}) => {
timestamp = getLongTimestampInMillis(timestamp);
return (
<>
<h6>{keyDate.title}</h6>
<p className="infoItem">{moment(timestamp).format(keyDate.dateFormat)}</p>
<h6 className="keyDateTitle">{keyDate.title}</h6>
<li className="infoItem keyDateValue">{(timestamp !== 0)? moment(timestamp).format(keyDate.dateFormat) : "N/A"}</li>
</>
)
} catch (e) {
return (
<>
<h6>{keyDate.title}</h6>
<p className="infoItem"></p>
<h6 className="keyDateTitle">{keyDate.title}</h6>
<li className="infoItem keyDateValue"></li>
</>
)
}
Expand All @@ -68,16 +68,15 @@ export const KeyDatesInfo = ({consent, infoLabels, consentType}) => {

return (
<>
<h6>{keyDate.title}</h6>
<p className="infoItem">{moment(fromTime).format(keyDate.dateFormat)} -
{moment(toTime).format(keyDate.dateFormat)}</p>
<h6 className="keyDateTitle">{keyDate.title}</h6>
<li className="infoItem keyDateValue">{moment(fromTime).format(keyDate.dateFormat)} - {(toTime !== 0)?moment(toTime).format(keyDate.dateFormat):"N/A"}</li>
</>
)
} catch (e) {
return (
<>
<h6>{keyDate.title}</h6>
<p className="infoItem"></p>
<h6 className="keyDateTitle">{keyDate.title}</h6>
<li className="infoItem keyDateValue"></li>
</>
)
}
Expand All @@ -90,27 +89,34 @@ export const KeyDatesInfo = ({consent, infoLabels, consentType}) => {
valueFromConsent = "N/A";
} else if (valueParameterKey === "receipt.Data.Initiation.InstructedAmount") {
valueFromConsent = `${valueFromConsent.Amount} ${valueFromConsent.Currency}`;
} else if (valueParameterKey === "consentAttributes.sharing_duration_value") {
const intValue = parseInt(valueFromConsent, 10);
if (intValue >= 0 && intValue <= 86400) {
valueFromConsent = "OnceOff";
} else {
valueFromConsent = "Ongoing";
}
}

return (
<>
<h6>{keyDate.title}</h6>
<p className="infoItem">{valueFromConsent}</p>
<h6 className="keyDateTitle">{keyDate.title}</h6>
<li className="infoItem keyDateValue">{valueFromConsent}</li>
</>
)
} catch (e) {
return (
<>
<h6>{keyDate.title}</h6>
<p className="infoItem"></p>
<h6 className="keyDateTitle">{keyDate.title}</h6>
<li className="infoItem keyDateValue"></li>
</>
)
}
} else {
return (
<>
<h6>{keyDate.title}</h6>
<p className="infoItem">{keyDate.text}</p>
<h6 className="keyDateTitle">{keyDate.title}</h6>
<li className="infoItem keyDateValue">{keyDate.text}</li>
</>
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
*/

import React from "react";
import base64url from "base64url";
import {decode as base64_decode } from 'base-64';
import wso2Logo from "../images/wso2Logo.png";

export const ResponseError = (error = {}) => {
Expand All @@ -32,8 +32,8 @@ export const ResponseError = (error = {}) => {
description = url.searchParams.get("description");

if (message && description) {
message = base64url.decode(message);
description = base64url.decode(description);
message = base64_decode(message);
description = base64_decode(description);
} else {
message = "Redirecting Failed!";
description =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -222,13 +222,18 @@ export const AdvanceSearch = () => {
className="sBorder"
title="submit search"
onClick={() => {
let userId = searchUser;
let userIdList = [userId];
if (userId.length > 0 && userId.indexOf(CONFIG.TENANT_DOMAIN) === -1) {
userIdList.push(userId + "@" + CONFIG.TENANT_DOMAIN);
}
let search = {
...searchObj,
limit: searchLimit,
offset: 0,
dateRange: dateRange,
consentIDs: consentId,
userIDs: searchUser,
userIDs: userIdList,
clientIDs: softwareId,
}
setContextSearchObject(search)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,7 @@
*/

export const common = {
footerContent: "WSO2 Open Banking | " + new Date().getFullYear(),
complaintHandleLinkText: "Complaint handling and resolution",
footerContent: "WSO2 Open Banking | " + new Date().getFullYear()
};

export const keyDateTypes = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"@testing-library/user-event": "^7.2.1",
"archiver": "^5.3.1",
"axios": "^0.27.2",
"base64url": "^3.0.1",
"base-64": "^1.0.0",
"bootstrap": "^4.5.3",
"date-fns": "^2.17.0",
"html2canvas": "^1.0.0-rc.7",
Expand Down Expand Up @@ -70,5 +70,9 @@
"moduleNameMapper": {
"overrideConfig": "<rootDir>/public/overrides/overrideConfig.js"
}
},
"engines": {
"node": ">=18.16.0",
"npm": ">=9.7.0"
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public class OAuthCallbackServlet extends HttpServlet {
private static final long serialVersionUID = -1253188744670051774L;
private static final Log LOG = LogFactory.getLog(OAuthCallbackServlet.class);
private static final String CODE = "code";
private static final String ERROR = "error";
private static final String ERROR_DESCRIPTION = "error_description";

@Generated(message = "Ignoring since all cases are covered from other unit tests")
@Override
Expand All @@ -69,6 +71,14 @@ protected void doGet(HttpServletRequest req, HttpServletResponse resp) {
// add cookies to response
oAuthService.generateCookiesFromTokens(tokenResponse, req, resp);
}
if ("access_denied".equals(req.getParameter(ERROR))) {
LOG.debug("User denied the consent. Error: " + req.getParameter(ERROR) +
"Error Description:" + req.getParameter(ERROR_DESCRIPTION));
SCPError error = new SCPError(req.getParameter(ERROR), req.getParameter(ERROR_DESCRIPTION));
final String errorUrlFormat = iamBaseUrl + "/consentmgr/error?message=%s&description=%s";
Utils.sendErrorToFrontend(error, errorUrlFormat, resp);
return;
}
LOG.debug("Redirecting to frontend application: " + redirectUrl);
resp.sendRedirect(redirectUrl);
} catch (TokenGenerationException | IOException e) {
Expand Down
Loading