Table of Contents

User Management

This module exports functions that controls users declarations.

Use require( hop.user ) to use it.

user.add( user )

Declares a new user in the Hop user database.

User identification is demanded by the Web server to reply to HTTP request. When the server receives a request, it first try to authenticate it. If the authentication fails, it responses with a 403 Forbidden response. Otherwise, it checks if the authentication user is allowed to be responded by checking the user services and user directories.

Note: The function user.add can only be called before the Hop server starts. It must then be called from the Hop rc-file, or from of the module required by hoprc.js, or from one of the modules mentionned on the command line. The rc-fileis loaded before the modules mentionned on the command line, so user.add instructions in user modules will overwrite conflicting rc-file instructions. The default location for the rc-fileis $HOME/.config/hop/hoprc.js, which can be changed using the --rc-file command line option.

The attributes of the user parameter are:


var hop = require( "hop" );
var user = require( hop.user );
var config = require( hop.config );

user.add( { name: "music-player",
            password: "+2606e88da9174caa886db5b916f3cd79",
            groups: [ "music" ],
            services: [ "public", "hopdac" ],
            directories: config.path.concat( [
               process.env.HOME + "/prgm/project/hop/weblets/hopdac",
               "/mmedia/music" ] )
          } );

user.encryptPassword( name, password )

Compute the encrypted password for user name and clear password.


user.encryptPassword( "dupont", "K555`!e" );