Skip to content
This repository has been archived by the owner on May 22, 2020. It is now read-only.

RUN-3120 prevent API calls from unauthenticated WS connections #123

Merged
merged 1 commit into from
Aug 7, 2017
Merged

RUN-3120 prevent API calls from unauthenticated WS connections #123

merged 1 commit into from
Aug 7, 2017

Conversation

whyn07m3
Copy link
Contributor

@whyn07m3 whyn07m3 commented Jul 31, 2017

ℹ️ Adds auth middleware that prevents unauthenticated WebSocket connections making API calls.


New Test
WS API call w/o authentication


⚠️ Diff for /api_handlers/authorization.js file looks crazy (because of indentation changes throughout the file), but the only changes to that file are:

  1. Made it NOT be a class
  2. added init function in place of previously having to instantiate class
  3. added auth middleware function isConnectionAuthenticated and its registration in registerMiddleware

Test Results (ignore new multi-preload scripts test errors, they are invalid)
Windows 7
Windows 10
• Node-adapter all (84) tests passed
• Java-adapter all tests passed

Copy link
Contributor

@HarsimranSingh HarsimranSingh left a comment

Choose a reason for hiding this comment

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

Looks good otherwise 👍


// Prevent all API calls from unauthenticated external connections,
// except for authentication APIs
if (
Copy link
Contributor

Choose a reason for hiding this comment

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

:neckbeard: this if statement looks kinda ugly. Maybe move the conditions out into variables with descriptive names.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done it this way initially to short-circuit checks, but agree with clarity over cleverness.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@HarsimranSingh after taking a look at this again, after Ricardo pointed it out, one of the calls here is an expensive one, and we have to give up clarity here a bit

HarsimranSingh
HarsimranSingh previously approved these changes Aug 7, 2017
};

module.exports.registerMiddleware = function(requestHandler) {
requestHandler.addPreProcessor(isConnectionAuthenticated);
Copy link
Member

Choose a reason for hiding this comment

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

this code executes for every request, can we short circuit it early, before we get the connectionByUuid.

Something like:

if (isExternalConnection) {
    next();
} else {
    //check if is authenticated and either next or nack.
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

brought short-circuiting back

@whyn07m3
Copy link
Contributor Author

whyn07m3 commented Aug 7, 2017

✅ Test results:
Windows 7
Windows 10
• Java-adapter all 59 tests pass
• Node-adapter all 84 tests pass

@rdepena
Copy link
Member

rdepena commented Aug 7, 2017

👍

@rdepena rdepena merged commit 68abbd8 into HadoukenIO:develop Aug 7, 2017
@whyn07m3 whyn07m3 deleted the RUN-3120_auth_ext_conn branch August 7, 2017 20:49
pbaize pushed a commit to pbaize/core that referenced this pull request Oct 18, 2019
* RUN-3996 fixed a multi-runtime regression (HadoukenIO#109)

* V bump.30.2 (HadoukenIO#110) (HadoukenIO#111)

* RUN-3996 fixed a multi-runtime regression (HadoukenIO#109)

* Version bump to 30.2

* RUN-3999 multi runtime tests config update (HadoukenIO#112)

* V bump.30.2 (HadoukenIO#110)

* RUN-3996 fixed a multi-runtime regression (HadoukenIO#109)

* Version bump to 30.2

* RUN-3999 Update multi runtime tests config

* Bug/run 3965 multi runtime cache clearing issue (HadoukenIO#114)

* V bump.30.2 (HadoukenIO#110)

* RUN-3996 fixed a multi-runtime regression (HadoukenIO#109)

* Version bump to 30.2

* RUN-3965 Fix EPERM: operation not permitted

* RUN-3965 Fix some cache folders not deleted issue

* RUN-4017/services (HadoukenIO#113)

* passing tests

* made changes

* RUN-4028 -  Async add listener (HadoukenIO#115)

* V bump.30.2 (HadoukenIO#110)

* RUN-3996 fixed a multi-runtime regression (HadoukenIO#109)

* Version bump to 30.2

* some test fixes

* more timeouts in tests

* altered tests to check for awaiting newlistener

* undo unnecessary edit

* fix types of registereventlistener and unregister

* hold, fixed removeAllListeners but need to test

* added some tests

* added testing

* cleanup

* fix prependonce

*  bit more testing

* revert test changes

* changed class name, some cleanup

* make tests match new best practices

* name of test file

* tests cleanup

* back to arrows for tslint

* bind rawsend (HadoukenIO#116)

* RUN-4045 register window name early in creation (HadoukenIO#117)

* RUN-4033 plugin.import accepts a string (HadoukenIO#118)

* Feature/test sledghammer (HadoukenIO#119)

* sledghammer approach to fixing tests.

* taking a sledghammer to our Multi runtime tests.

* Moving back to es6 untill we hit a major version.

* A few items from the code review.

* code review items.

* code review items.

* V bump.30.2 (HadoukenIO#110) (HadoukenIO#121)

* RUN-3996 fixed a multi-runtime regression (HadoukenIO#109)

* Version bump to 30.2

* RUN-3898 - External services tests (HadoukenIO#120)

* hiold

* hold

* tests for external services re RUN-3898

* clean up

* Test fixed, no longer leaving around runtime (HadoukenIO#122)

* test fixed, no longer leaving around runtime

* cleanup

* Fixed issue with the webpack grunt task where it was not reporting the errors correctly (HadoukenIO#123)

* Fixed issue with the webpack grunt task where it was not reporting the errors correctly

* Passing error codes instead of arrays.

* version bump. (HadoukenIO#124)
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants