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

add session based authentication for rpc #175

Merged
merged 8 commits into from
Jul 9, 2018

Conversation

vaishnavachath
Copy link
Contributor

  • used express-session middleware to handle the session(added as dependency)
  • used basic-auth to handle authentication(added as dependency)
  • modify the startclient to send cookie data
  • modify the startServer to accept credentials
  • tested both from browser and via node, works well

also add some comments for previous modifications made

add code comments wherever necessary for changes made as part of
GSoC '18 work
used express-session middleware to handle the session(added as dependency)
used basic-auth to handle authentication(added as dependency)
modify the startclient to send cookie data
modify the startServer to accept credentials
tested both from browser and via node, works well
@coveralls
Copy link

coveralls commented Jun 25, 2018

Coverage Status

Coverage increased (+13.6%) to 59.372% when pulling 118f3e9 on vaishnav98:master into 481525c on jadonk:master.

Copy link
Owner

@jadonk jadonk left a comment

Choose a reason for hiding this comment

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

I need to test this in the buster-iot images as well. First thing to fix is to pass the login and socket.io connections over to this client. To simplify things, would it make better sense if the security was done WITHIN the socket.io connection, rather than at the Express server level?

@@ -7,7 +7,9 @@ _bonescript.on.connect = function () {};
_bonescript.on.connecting = function () {};
_bonescript.on.disconnect = function () {};
_bonescript.on.connect_failed = function () {};
_bonescript.on.error = function () {};
_bonescript.on.error = function (err) {
throw (new Error(err))
Copy link
Owner

Choose a reason for hiding this comment

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

This runs asynchronously on load when loaded by a browser? How do we catch this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I am not very sure how we will be able to catch this error from the browser , however if the current implementation is used, then a 401 Unauthorized response could be sent for unauthorized sessions from browser.


exports.setUp = function (callback) {
server.serverStart(8000, process.cwd(), { // create a secure server by supplying credentials
username: 'testuser',
Copy link
Owner

Choose a reason for hiding this comment

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

For "production" use, these need to be stored statically in a file. Where is the associated update to server.js (not src/server.js)? That file should be updated to read all parameters from a configuration file. Perhaps use /etc/default/bonescript?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Sure, i will modifications for that, will use /etc/default/bonescript for the default config. I did not modify the server.js till now as i noticed that it starts the server with default settings, will make changes to it soon.

@jadonk
Copy link
Owner

jadonk commented Jun 25, 2018

The coverage check should be considered a requirement now. We have a lot of untested code, so it shouldn't be hard to increase the coverage %.

@vaishnavachath
Copy link
Contributor Author

Sure, I will concentrate on increasing the coverage too when making the modifications

authentication at express level was removed and was implemented at
the socket.io connection through extraheaders, corresponding modification
was made at server and client
* username & password send as basic authentication headers
* modified server.js to read config file from /etc/default/bonescript
the config file format used was :
{
 "username":"debian",
 "password":"temppwd",
 "port": 8000 ,
 "directory": "/usr/share/bone101"
 }
* need to add more test cases and make other improvements
expression session dependency was removed and simple socket.io middleware
 hash-challenge was used for authentication, modified the client and
server for the changes the passphrase can be supplied to serverstart already
as hash or as plaintext: the configuration files used for testing server.js were:
{
 "hash": true,
 "passphrase":"9f735e0df9a1ddc702bf0a1a7b83033f9f7153a00c29de82cedadc9957289b05",
 "port": 8000 ,
 "directory": "/usr/share/bone101"
 }
and
{
 "hash": false,
 "passphrase":"testpassword",
 "port": 8000 ,
 "directory": "/usr/share/bone101"
 }

also other unnecessary dependencies were removed, need to add test cases
modified rpc tests to increase converage
added analogWrite(), digitalWrite() and pinMode() tests
modified test-ffi to include callback cases
added test-math based on pattern of math functions
added test-digitalRead() and test-analogRead()
in the case of analogWrite() on digital out, the callbacks were invoked
twice everytime, found while writing a test-case
the callback on digitalWrite on AnalogOut was never invoked
due to error in arguments supplied to analogWrite()
Copy link
Owner

@jadonk jadonk left a comment

Choose a reason for hiding this comment

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

Good enough. I think we need to change the /etc/default/bonescript format to be more like a typical 'variable = value\n' style text document, but we can work towards that. I'm counting on your testing here!

@jadonk jadonk merged commit 70f1d73 into jadonk:master Jul 9, 2018
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.

3 participants