ocolin/bx-auth

Tool for authenticating using Billmax Auth database

Maintainers

Details

github.com/ocolin/BxAuth

Source

Issues

Installs: 0

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 0

Forks: 0

Open Issues: 0

pkg:composer/ocolin/bx-auth

1.0 2026-02-13 21:45 UTC

This package is auto-updated.

Last update: 2026-02-13 21:47:47 UTC


README

Database Authentication for Billmax

This package is not written with any public use in mind. It's an experiment for allowing external apps to login using the authentication in the Billmax billing software.

Instantiation

To connect to the database to verify authentication we need 4 pieces of information:

  • host - Name/IP of billmax server. Defaults to localhost.
  • name - Name of the database table. Defaults to billmax.
  • user - Username of database user.
  • pass - Password of database user.

Environment variables

The constructor arguments can be provided directly, or environment variables can be used instead:

  • BILLMAX_DB_HOST
  • BILLMAX_DB_NAME
  • BILLMAX_DB_USER
  • BILLMAX_DB_PASS

See ,env.example file.

Example - Constructor arguments

$auth = new \Ocolin\BxAuth\BxAuth(
    host: 'localhost',
    name: 'billmax',
    user: 'myusername',
    pass: 'mypassword'
);

Example - Environment variables

$_ENV['BILLMAX_DB_HOST'] = 'localhost';
$_ENV['BILLMAX_DB_NAME'] = 'billmax';
$_ENV['BILLMAX_DB_USER'] = 'myusername';
$_ENV['BILLMAX_DB_PASS'] = 'mypassword';

$auth = new \Ocolin\BxAuth\BxAuth();

Calls

Login

  • user - Username to log in as.
  • pass - Password to long in with.
  • session - Create a PHP session and add data to it.
$data = $auth->login(
    user: 'bobsuncle',
    pass: 'tiddlywinks',
    session: true
);

print_r( $_SESSION );

Array
(
    [LOGGED_IN] => 1
    [AUTH] => Ocolin\BxAuth\AuthData Object
        (
            [id] => 86
            [access] => 31
            [descr] => Bob Uncle
            [email] => bob@staff.test.com
            [user] => bobsuncle
            [fname] => Bob
            [lname] => Uncle
            [password] => $1$UV$hR/8uhVeBpD5Wzb0V7Dyz/
        )

)

By default the function returns an object with the user data in it. Setting seesion to true will add that data to $_SESSION['AUTH'].

Logout

This will log the user out, destroy the cookie, and wipe any session variables.

$auth->logout();

Check Login

Check to see if we are currently logged in. Return true or false.

$loggedin = $auth->check_Login();

var_dump( $loggedin );

bool(true)