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

[Backport 2024.01.xx]: #10414: Remove the list of associated groups of logged in user from the User Details modal window (#10415) #10447

Merged
Merged
Show file tree
Hide file tree
Changes from 3 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
47 changes: 47 additions & 0 deletions docs/developer-guide/mapstore-migration-guide.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,53 @@ This is a list of things to check if you want to update from a previous version
- Optionally check also accessory files like `.eslinrc`, if you want to keep aligned with lint standards.
- Follow the instructions below, in order, from your version to the one you want to update to.

## Migration from 2024.01.00 to 2024.01.02

### Option to hide the group info of logged in user from user details modal window

Recently, we have added the option to hide the `user group info` from the user details modal.
To enable this, you have to add a cfg in all `Login` plugin into `localConfig.json` like:

```json
{
"name": "Login",
"cfg": { "toolsCfg": [{"hideGroupUserInfo": true}] }
}
```

where the first index of toolsCfg is for `userDetails` component that is responsible for displaying the user details including `user group info`

!!! note important notes should be considered:

- if you have customized the Login plugin and in particular the order of toolsCfg, make sure to override the correct one as the propagation of cfg for the tools is based on index value.

### Integration with openID Connect

A generic OpenID Connect (OIDC) authentication support has been introduced in MapStore. This feature allows to authenticate users using an OIDC provider, like Keycloak, Okta, Google, Azure, etc.

To provide this functionality, it is necessary to update the project's `geostore-spring-security.xml` file, if the default one is not used.
If you are using the default one, you can skip this step.

Here the changes to apply if needed:

```diff
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@mahmoudadel54 please fix conflicts and double check your PR after you create it comparing it with the previous one in case of backports to ensure you are contributing the same contents.

@@ -24,6 +24,7 @@
<security:custom-filter ref="sessionTokenProcessingFilter" after="FORM_LOGIN_FILTER"/>
<security:custom-filter ref="keycloakFilter" before="BASIC_AUTH_FILTER"/>
<security:custom-filter ref="googleOpenIdFilter" after="BASIC_AUTH_FILTER"/>
+ <security:custom-filter ref="oidcOpenIdFilter" before="OPENID_FILTER"/> <!-- ADD a filter with this ref -->
<security:anonymous />
</security:http>

@@ -52,6 +53,7 @@

<!-- OAuth2 beans -->
<context:annotation-config/>
+ <bean id="oidcSecurityConfiguration" class="it.geosolutions.geostore.services.rest.security.oauth2.openid_connect.OpenIdConnectSecurityConfiguration"/> <!-- add this bean to configure the integration -->

<bean id="googleSecurityConfiguration" class="it.geosolutions.geostore.services.rest.security.oauth2.google.OAuthGoogleSecurityConfiguration"/>
```

## Migration from 2023.02.02 to 2024.01.00

### TOC plugin refactor
Expand Down
23 changes: 15 additions & 8 deletions web/client/components/security/modals/UserDetailsModal.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ import { isArray, isObject, isString } from 'lodash';

/**
* A Modal window to show password reset form
* @prop {bool} hideGroupUserInfo It is a flag from Login plugin (cfg.toolsCfg[0].hideGroupUserInfo): to show/hide user group in user details info, by default `false`
*/
class UserDetails extends React.Component {
static propTypes = {
Expand All @@ -26,7 +27,8 @@ class UserDetails extends React.Component {
show: PropTypes.bool,
options: PropTypes.object,
onClose: PropTypes.func,
includeCloseButton: PropTypes.bool
includeCloseButton: PropTypes.bool,
hideGroupUserInfo: PropTypes.bool
};

static defaultProps = {
Expand All @@ -35,23 +37,28 @@ class UserDetails extends React.Component {
},
onClose: () => {},
options: {},
includeCloseButton: true
includeCloseButton: true,
hideGroupUserInfo: false
};

getUserInfo = () => {
return {
let mainUserInfo = {
name: v => <strong>{v}</strong>,
role: v => <strong>{this.capitalCase(v)}</strong>,
email: v => <strong>{v}</strong>,
company: v => <strong>{v}</strong>,
notes: v => <strong>{v}</strong>,
groups: groups => {
notes: v => <strong>{v}</strong>
};

if (!this.props.hideGroupUserInfo) {
mainUserInfo.groups = groups => {
const gr = isArray(groups) && [...groups] || groups.group && isArray(groups.group) && [...groups.group] || groups.group && isObject(groups.group) && [{...groups.group}];
return gr && gr.map(group => {
return group.groupName && <div key={group.groupName}><strong>{group.groupName}</strong></div> || null;
return group.groupName && <div className="user-group-info" key={group.groupName}><strong>{group.groupName}</strong></div> || null;
}).filter(v => v) || null;
}
};
};
}
return mainUserInfo;
}

renderAttributes = () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,4 +75,49 @@ describe("Test user details modal", () => {

expect(modalDOM.getElementsByClassName('row').length).toEqual(6);
});
it('test hide group user info if hideGroupUserInfo = true', () => {
let testUser = {
"attribute": [
{
"name": "company",
"value": "Some Company"
},
{
"name": "email",
"value": "[email protected]"
},
{
"name": "notes",
"value": "some notes"
},
{
"name": "UUID",
"value": "260a670e-4dc0-4719-8bc9-85555d7dcbe1"
}
],
"enabled": true,
"groups": {
"group": {
"enabled": true,
"groupName": "everyone",
"id": 3
}
},
"id": 6,
"name": "admin",
"role": "ADMIN"
};
let displayAttributes = (attr) => {
return attr.name && attr.name === "email" || attr.name === "company";
};
const cmpNormal = ReactDOM.render(<UDModal options={{animation: false}} show displayAttributes={displayAttributes} user={testUser}/>, document.getElementById("container"));
expect(cmpNormal).toExist();
const modalDOMNormal = document.getElementsByClassName('ms-resizable-modal')[0];
expect(modalDOMNormal.querySelector('.user-group-info')).toExist(); // includes group info

const cmpWithHide = ReactDOM.render(<UDModal hideGroupUserInfo options={{animation: false}} show displayAttributes={displayAttributes} user={testUser}/>, document.getElementById("container"));
expect(cmpWithHide).toExist();
const modalDOM = document.getElementsByClassName('ms-resizable-modal')[0];
expect(modalDOM.querySelector('.user-group-info')).toNotExist(); // not include group info
});
});
Loading