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

OAuth having problems if a dot is an attribute in the Identity Path #13220

Closed
Centzilius opened this issue Jan 22, 2019 · 2 comments · Fixed by #15690
Closed

OAuth having problems if a dot is an attribute in the Identity Path #13220

Centzilius opened this issue Jan 22, 2019 · 2 comments · Fixed by #15690

Comments

@Centzilius
Copy link

Description:

When using Azure AD as OAuth2 provider and using https://graph.microsoft.com/v1.0/me/ as Identity Path you get the following error on log in (server log):

{"line":"392","file":"oauth_server.js","message":"Error in OAuth Server: Key @odata.context must not contain '.'","time":{"$date":1548170235154},"level":"warn"}
Exception while invoking method 'login' { MinimongoError: Key @odata.context must not contain '.'
    at MinimongoError (packages/minimongo/common.js:1087:17)
    at assertIsValidFieldName (packages/minimongo/local_collection.js:1889:11)
    at Object.JSON.stringify (packages/minimongo/local_collection.js:1880:7)
    at JSON.stringify (<anonymous>)
    at assertHasValidFieldNames (packages/minimongo/local_collection.js:1879:10)
    at Function.LocalCollection._modify (packages/minimongo/local_collection.js:1184:5)
    at Function.LocalCollection._createUpsertDocument (packages/minimongo/local_collection.js:935:19)
    at MongoConnection._update (packages/mongo/mongo_driver.js:546:38)
    at MongoConnection.<anonymous> (packages/meteor.js:376:21)
    at MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:754:49)
    at Collection.update (packages/mongo/collection.js:585:31)
    at Collection.upsert (packages/mongo/collection.js:655:17)
    at Object.OAuth._storePendingCredential (packages/oauth/pending_credentials.js:56:29)
    at OAuth._requestHandlers.(anonymous function) (packages/oauth2/oauth2_server.js:17:11)
    at middleware (packages/oauth/oauth_server.js:161:5)
    at /app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40
  message: 'Key @odata.context must not contain \'.\'',
  name: 'MinimongoError',
  futureStack: 'MinimongoError: Key @odata.context must not contain \'.\'\n    at MinimongoError (packages/minimongo/common.js:1087:17)\n    at assertIsValidFieldName (packages/minimongo/local_collection.js:1889:11)\n    at Object.JSON.stringify (packages/minimongo/local_collection.js:1880:7)\n    at JSON.stringify (<anonymous>)\n    at assertHasValidFieldNames (packages/minimongo/local_collection.js:1879:10)\n    at Function.LocalCollection._modify (packages/minimongo/local_collection.js:1184:5)\n    at Function.LocalCollection._createUpsertDocument (packages/minimongo/local_collection.js:935:19)\n    at MongoConnection._update (packages/mongo/mongo_driver.js:546:38)\n    at MongoConnection.<anonymous> (packages/meteor.js:376:21)\n    at MongoConnection.(anonymous function) [as update] (packages/mongo/mongo_driver.js:754:49)\n    at Collection.update (packages/mongo/collection.js:585:31)\n    at Collection.upsert (packages/mongo/collection.js:655:17)\n    at Object.OAuth._storePendingCredential (packages/oauth/pending_credentials.js:56:29)\n    at OAuth._requestHandlers.(anonymous function) (packages/oauth2/oauth2_server.js:17:11)\n    at middleware (packages/oauth/oauth_server.js:161:5)\n    at /app/bundle/programs/server/npm/node_modules/meteor/promise/node_modules/meteor-promise/fiber_pool.js:43:40' }

The content of https://graph.microsoft.com/v1.0/me/ is the following:

{
    "@odata.context": "https://graph.microsoft.com/v1.0/$metadata#users/$entity",
    "businessPhones": [
        "+49XXX"
    ],
    "displayName": "Vincent Post",
    "givenName": "Vincent",
    "jobTitle": "Support Engineer",
    "mail": "[email protected]",
    "mobilePhone": null,
    "officeLocation": "Universe, Galaxy",
    "preferredLanguage": null,
    "surname": "Post",
    "userPrincipalName": "[email protected]",
    "id": "b89de1d0-1e5c-11e9-b56e-0800200c9a66"
}

Server Setup Information:

  • Version of Rocket.Chat Server: 0.73.2
  • Operating System: CentOS 7
  • Deployment Method: docker
  • Number of Running Instances: 1
  • DB Replicaset Oplog: Disabled
  • NodeJS Version: 8.11.4 - x64
  • MongoDB Version: docker container mongo:3.2

This might be related to #10931

@geekgonecrazy
Copy link
Contributor

I’m not sure how to handle this one. We save the response. But mongo doesn’t support fields with a dot in the name. So mongo rejects the save

@Centzilius
Copy link
Author

I suggest replacing every unsupported character or simply ignoring it since rocketchat is not going to use it anyway.

I wanted to use the openid endpoint originally but then the mail address is not picked up by rocket chat (probably because it's not the key "mail") so to use that it would be needed to customize the field that is used for mail.

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