Skip to content

add session based authentication for rpc - #175

Merged
jadonk merged 8 commits into
jadonk:masterfrom
vaishnavachath:master
Jul 9, 2018
Merged

jadonk merged 8 commits into
jadonk:masterfrom
vaishnavachath:master

Conversation

@vaishnavachath

Copy link
Copy Markdown
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

coveralls commented Jun 25, 2018 •

Copy link
Copy Markdown

Coverage Status

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

@jadonk jadonk left a comment

Copy link
Copy Markdown
Owner

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?

Comment thread src/bonescript.js
_bonescript.on.connect_failed = function () {};
_bonescript.on.error = function () {};
_bonescript.on.error = function (err) {
throw (new Error(err))

Copy link
Copy Markdown
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
Copy Markdown
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.

Comment thread test/test-rpc_secure.js Outdated

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

Copy link
Copy Markdown
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
Copy Markdown
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

jadonk commented Jun 25, 2018

Copy link
Copy Markdown
Owner

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
Copy Markdown
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
@vaishnavachath
vaishnavachath force-pushed the master branch 12 times, most recently from f805590 to 9c2284b Compare June 29, 2018 23:07
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
@vaishnavachath
vaishnavachath force-pushed the master branch 3 times, most recently from b458da2 to f149b56 Compare July 2, 2018 08:43
the callback on digitalWrite on AnalogOut was never invoked
due to error in arguments supplied to analogWrite()

@jadonk jadonk left a comment

Copy link
Copy Markdown
Owner

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