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

Unable to add device groups while using SAML causes crash (email as userid) #6596

Open
liv-acollins opened this issue Dec 9, 2024 · 6 comments
Labels

Comments

@liv-acollins
Copy link

Describe the bug
When creating a new group MeshCentral appears to crash and then restart itself. Error log contains:

/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:31
  if (k.indexOf('.') !== -1) throw new Error('Field names cannot contain a .')
                                   ^

Error: Field names cannot contain a .
    at checkKey (/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:31:36)
    at checkObject (/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:50:9)
    at checkObject (/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:51:9)
    at Object.checkObject (/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:51:9)
    at Datastore._prepareDocumentForInsertion (/opt/meshcentral/node_modules/@seald-io/nedb/lib/datastore.js:737:13)
    at Datastore._insertAsync (/opt/meshcentral/node_modules/@seald-io/nedb/lib/datastore.js:699:30)
    at /opt/meshcentral/node_modules/@seald-io/nedb/lib/datastore.js:800:47
    at /opt/meshcentral/node_modules/@seald-io/nedb/lib/waterfall.js:28:16

This has only just started happening. It was either caused by a version update or due to us having 25 groups - this would be our 26th device group.

To Reproduce
Steps to reproduce the behavior:
With 25 groups active. Click 'New' next to Device Groups on My Account. New Device Group popup will appear, enter details, e.g. Name="Test" - Click 'OK'. MeshCentral then changes page to 'Server Disconnected'. The error above mentions a field cannot contain ".", this character isn't being used in the field name so something else is triggering it.

Expected behavior
New empty group you should be added.

Server Software (please complete the following information):

  • OS: RockyLinux 9.5
  • Virtualization: None (VMWare host)
  • Network: LAN
  • Version: 1.1.35
  • Node: 16.20.2-8.el9_4

Client Device (please complete the following information):

  • Device: Desktop + Laptop
  • OS: Windows 10 22H2
  • Network: Local
  • Browser: Firefox
  • MeshCentralRouter Version: N/A

Remote Device (please complete the following information):
N/A

Additional context
Add any other context about the problem here.

Your config.json file

{
  "settings": {
    "cert": "xxxx",
    "meshErrorLogPath": "/var/log/meshcentral/",
    "authLog": "/var/log/meshcentral/auth.log",
    "log": "authlog,web"
  },
  "domains": {
    "": {
      "authStrategies": {
        "saml": {
          "callbackUrl": "xxxx",
          "entityid": "xxxx",
          "idpurl": "xxxx",
          "cert": "xxxx"
        }
      },
      "newAccounts": true,
      "showPasswordLogin": false,
      "title": "xxxx",
      "title2": "xxxx",
      "welcomePicture": "welcome.png",
      "footer": "xxxx"
    }
  }
}

@liv-acollins
Copy link
Author

liv-acollins commented Dec 13, 2024

I modified the error to show the value of k.

/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:31
  if (k.indexOf('.') !== -1) throw new Error('Field names cannot contain a . "' + k + '"')
                                   ^

Error: Field names cannot contain a . "user//~saml:[email protected]"
    at checkKey (/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:31:36)
    at checkObject (/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:50:9)
    at checkObject (/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:51:9)
    at Object.checkObject (/opt/meshcentral/node_modules/@seald-io/nedb/lib/model.js:51:9)
    at Datastore._prepareDocumentForInsertion (/opt/meshcentral/node_modules/@seald-io/nedb/lib/datastore.js:737:13)
    at Datastore._insertAsync (/opt/meshcentral/node_modules/@seald-io/nedb/lib/datastore.js:699:30)
    at /opt/meshcentral/node_modules/@seald-io/nedb/lib/datastore.js:800:47
    at /opt/meshcentral/node_modules/@seald-io/nedb/lib/waterfall.js:28:16

As we use SAML, our usernames are email addresses which is trigger the "." check. I believe this must have been triggered by an update as this worked until recently.

@liv-acollins liv-acollins changed the title Adding device group causes crash Unable to add device groups while using SAML causes crash (email as userid) Dec 13, 2024
@si458
Copy link
Collaborator

si458 commented Dec 13, 2024

Ah right ok!

We already have a function built in which should convert the full stops to like fullstops that nedb can understand so we might of missed one :)

Will look at it next week or when I get chance :)

In the mean time the better way is
not use fullstops for things so change it from email to like username or a random id
OR
Don't use nedb, switch to another database like sqlite or mongodb or something else

@liv-acollins
Copy link
Author

Thanks @si458, is their a migration guide for moving to monodb/sqlite from nedb?

@si458
Copy link
Collaborator

si458 commented Dec 13, 2024

It's very simple,

  1. Stop meshcentral
  2. Change ur config.json to whichever database u want
  3. Run node node_modules/meshcentral --nedbtodb
  4. (Maybe skip i can't remember) step 3 might quit so start meshcentral, if it doesn't, skip step 4, ur done :)

P.s if anything isnt working, stop meshcentral, uncomment/remove all databases in config.json, start meshcentral :)

@liv-acollins
Copy link
Author

Fantastic, thank you. Will give it a go when I feel brave enough.

@si458
Copy link
Collaborator

si458 commented Dec 13, 2024

You can also use the database export and import methods too https://ylianst.github.io/MeshCentral/meshcentral/#database
But this is to change between databases rather than from only nedb to another database

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants