Skip to content

Scrub MCWS user ID of invalid namespace characters#410

Merged
jvigliotta merged 6 commits intomainfrom
handle-username-special-chars
Apr 21, 2026
Merged

Scrub MCWS user ID of invalid namespace characters#410
jvigliotta merged 6 commits intomainfrom
handle-username-special-chars

Conversation

@jvigliotta
Copy link
Copy Markdown
Collaborator

@jvigliotta jvigliotta commented Mar 5, 2026

Fixes: #387 in v5.3.2.

This can't be tested with development storage, so you'll need something to emulate the MCWS persistence storage, as well as send a poorly-formatted name.

  1. clone https://github.jpl.nasa.gov/IEMS/iems-gds-fast-mcws-persistence
  2. cd into iems-gds-fast-mcws-persistence
  3. edit the following file: fastmio/fastMIOServer.py line 165
  4. replace remote_user='unknown' with remote_user='Unknown, User (999A)'
  5. edit the following file: fastmio/config/fastmio.cfg
    Line 26:
    import_mcws_namespaces = true -> import_mcws_namespaces = false
    Line 40:
    import_fastmio_namespaces=false -> import_fastmio_namespaces=true

Lines 44-48:

ns_map= {
"/shared":"/home/user/shared",
"/systems":"/home/user/systems",
"/users":"/home/user/users"
}

becomes

ns_map= {
"/shared":"/your/path/here/shared",
"/users":"/your/path/here/users"
}

  1. Create a python3 virtual environment and install fastmio's required packeges.

python3 -m venv fastmioenv
source fastmioenv/bin/activate
pip install -e .

Fastmio is now configured to send your development server a MCWS namespace with an invalid ID.

Run fast mio with python fastmio/fastMIOServer.py and leave the terminal up for your testing purposes.

Note that you may need to delete the contents of while you test - fastmio will automatically pick up any changes to the and does not need to be restarted if you do.

Next, configure the webpack dev environment and config.js to use the fastmio environment you just set up.

Webpack dev:
set your API_URL environment variable to localhost:8093

config.js

  1. set the mcwsUrl to:
    mcwsUrl: 'http://localhost:8093/mcws',
  2. Set the URLs for the development namespaces like so:

namespaces: [
{
key: 'r50-dev',
name: 'R5.0 Shared',
url: '/fastmio/shared'
},
{
userNamespace: true,
key: 'r50-dev',
name: 'R5.0 Users',
url: '/fastmio/users'
}
],

uncomment the proxyUrl line, but do not uncomment the useDeveloperStorage line, as we're going to use fastmio in this scenario as our test storage provider. Don't forget to remove the comma after useDeveloperStorage if it is now the last item in the config file.

running npm start should now run MCT as a developer server but with fastmio providing a fully qualified mcws-like name, allowing this functionality to be tested .

Verify that the user folder is automatically created with the full user name and that the logged in user in the MCT status bar is the correct user name.
Verify that if you create an object in the user's folder, the namespace and location parameters do not contain spaces, commas, or other invalid characters.
Verify that you can create objects in the shared folder with no issues as well.

@jvigliotta jvigliotta added this to the MC 2608 - Open MCT Release milestone Mar 5, 2026
@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Copy link
Copy Markdown
Collaborator

@davetsay davetsay left a comment

Choose a reason for hiding this comment

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

I'd like interpolateUsername and createIfMissing to follow the same arg order, id then name. I believe they are both internal functions so it shouldn't affect users.

Would like to examine the different user returns we could be getting. ie. CAM, LDAP, or, at least those two.

SonarCould analysis should be addressed if possible.

@davetsay davetsay self-requested a review April 17, 2026 21:13
Copy link
Copy Markdown
Collaborator

@davetsay davetsay left a comment

Choose a reason for hiding this comment

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

i had left a comment about param order. i think its a good idea but approving

@sonarqubecloud
Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
0.0% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

Comment thread src/persistence/utils.js
* @returns {NamespaceDefinition} a namespace definition object.
*/
export function interpolateUsername(templateObject, username) {
export function interpolateUsername(templateObject, userId, username = userId) {
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

👍

@jvigliotta jvigliotta merged commit e2877f2 into main Apr 21, 2026
2 of 3 checks passed
@jvigliotta jvigliotta deleted the handle-username-special-chars branch April 21, 2026 17:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MCWS Identity provider doesn't scrub user id of invalid characters.

2 participants