bluehalo / node-fhir-server-core

An Open Source secure REST implementation for the HL7 FHIR Specification. For API documentation, please see https://github.com/Asymmetrik/node-fhir-server-core/wiki.
https://asymmetrik.com/healthcare
MIT License
393 stars 122 forks source link

Middleware is not working because of a parameter #178

Closed mihaixyx closed 5 years ago

mihaixyx commented 5 years ago

Do you want to request a feature, report a bug, or improve documentation? A bug.

So I was trying to implement passportjs into a project based on this server, and I noticed that any middleware does not work.

The bug can be found while passing the config to the function authenticationMiddleware inside of src/server/router.js at the enableResourceRoutes function. Calling the function as "authenticationMiddleware( {config} )" creates a object that would look something like "config { config { } }", while the calls inside of the authenticationMiddleware() inside of the src/server/middleware/authentication.middleware.js treat the object just as a "config { }".

The problem can be solved by either calling authenticationMiddleware( config ) ( instead of authenticationMiddleware( {config} ) ) inside of the enableResourceRoutes, or by using "config.config.auth && config.config.auth.strategy" inside of the authentication.middleware file.

peturv commented 5 years ago

Ran into this issue myself yesterday. Added a PR here in case it's of use.

Robert-W commented 5 years ago

Thanks @mihaixyx and @peturv. We just got back from Dev days in Seattle so we'll work on getting this approved as soon as possible.

Robert-W commented 5 years ago

Fixed via #183, thanks @mihaixyx for reporting and @peturv for fixing !! We'll cut a new release once we got all these PR's merged in.