2 releases

0.1.1 Oct 13, 2023
0.1.0 Oct 13, 2023

#950 in Authentication

MIT license

24KB
261 lines

auth_lite

auth_lite is a lightweight authentication server tailored for web servers that utilize features like the nginx auth_request module. Instead of relying on traditional .htpasswd files, auth_lite employs a nimble SQLite database, making the management of credentials more efficient and seamless.

Installation

  1. Clone the repository:

    git clone https://github.com/jtdowney/auth_lite.git
    cd auth_lite
    
  2. Build the project:

    cargo build --release
    
  3. The compiled binary will be available in the target/release directory.

Setup

  1. Add a user:

    ./auth_lite add-user USERNAME
    

    This will prompt you for a password. Passwords are hashed and stored securely.

  2. Setup nginx:

    In your nginx configuration, incorporate the auth_request directive:

    location /protected/ {
        auth_request /_auth;
        ...
    }
    
    location = /_auth {
        internal;
        proxy_pass http://127.0.0.1:YOUR_AUTH_LITE_PORT/auth;
    }
    

    Make sure to replace YOUR_AUTH_LITE_PORT with the port auth_lite is listening on.

  3. Start the auth_lite server:

    ./auth_lite serve --port YOUR_AUTH_LITE_PORT
    

Usage

To manage users in the auth_lite SQLite database:

  • Add a user:

    ./auth_lite add-user USERNAME
    
  • List all users:

    ./auth_lite list-users
    
  • Remove a user:

    ./auth_lite remove-user USERNAME
    
  • Change a user's password:

    ./auth_lite change-password USERNAME
    

Contributing

Contributions are warmly welcomed! Whether it's bug reports, feature requests, or code contributions, please open an issue or a pull request.

License

auth_lite is licensed under the MIT License.

Dependencies

~55MB
~1M SLoC