Simple Secure Auth Package
Simple Secure Auth Package
This Lib is the beginings of an Authentication framework. It makes use of crypto
and sqlite3
to create, store, check hashed username / password combinations.
##Install
npm install ca-auth
##API
Inits authentication database
Parameters
Args: object, Only Real Param All Other Params should be properties of
Args
Args.hashkey: string, can be any string, should be random data with a lenght atleast as long as any password being hashed. Must be the same Value between runs or hashes will not match
Args.path: string, [optional] path to sqlite3 database if not set
_auth.db
in package root will be created / usedArgs.callback: function, [optional] called when DB is ready
Closes authentication database
Parameters
callback: function, [optional] called after db has ben closed
Creates User fails if user already exists
Parameters
Args: object, Only Real Param All Other Params should be properties of
Args
Args.username: string, Username String could also be hash
Args.userpass: string, Password String could also be hash
Args.callback: function, [optional] will be passed
error
,authID
error will be astring
error string ornull
, authID will be anull
orint
users authID
Authentication of users
Parameters
Args: object, Only Real Param All Other Params should be properties of
Args
Args.username: string, Username String could also be hash (must be same as what was used for
create
)Args.userpass: string, Password String could also be hash (must be same as what was used for
create
)Args.callback: function, [optional] will be passed
error
,authID
error will be astring
error string ornull
, authID will be anull
orint
users authID
Updates user data for a given userid fails if user does not exist
Parameters
Args: object, Only Real Param All Other Params should be properties of
Args
Args.userid: int, authUID of the user to be updated
Args.username: string, [optional] Username String could also be hash
Args.userpass: string, [optional] Password String could also be hash
Args.isEnabled: int, [optional] can be 0 or 1
Args.callback: function, [optional] will be passed
error
,authID
error will be astring
error string ornull
, authID will be anull
orint
users authID
Soft delete of user changes isEnabled to 0 preventing Authentication
Parameters
Args: object, Only Real Param All Other Params should be properties of
Args
Args.userid: int, authUID of the user to be deleted
Args.callback: function, [optional] will be passed
error
,authID
error will be astring
error string ornull
, authID will be anull
orint
users authID
##TODO:
Coding:
Testing / Doc:
- Doc API
Eventualy: =======
- Add Example Code
Eventualy:
- Change functions to take multiple Arguments instead of
Args
object- Implement Public Key Authentication
- Update Tests to check for changes on DB side after command
- Implement Permissions system
- Implement Logging system
####Disclaimer: This is a toy project, and should not be used for production grade anything ... use at your own risk