GithubHelp home page GithubHelp logo

liamjack / auth Goto Github PK

View Code? Open in Web Editor NEW
46.0 10.0 13.0 227 KB

PHP user authorization class, session data stored in database, secure password hashing, easily adaptable to any existing site !

PHP 100.00%

auth's Introduction

User Authentication PHP Class
=============================

This is a simple user authentication class for PHP, which uses
a MySQL Database which is accessed via MySQLi.

The system also includes a Custom user session system, meaning
sessions can last a predefined time, for example, 1 minute to over 10 years
if that was ever needed.

The Current functions are as follows :

- login($username, $password) : Verifies user credentials
- register($username, $password, $verifypassword, $email) : Adds a new user account to the database
- newsession($username) : Creates a new session for the user
- deletesession($hash) : Deletes an existing session from the database, and removes the user's cookie
- sessioninfo($hash) : Retrieves info about the session from database (UID, Username, Expire Date, IP)
- checksession($hash) : Checks if session is valid
- randomkey($length) : Returns a random key, used as activation key, contain lowercase / uppercase letters and numbers
- activate($username, $key) : Activates an account based on username and activation key
- changepass($username, $currpass, $newpass, $verifynewpass) : Changes the user's password. Requires current password
- changeemail($username, $email) : Changes the user's email
- resetpass($username, $email, $key, $newpass, $verifynewpass) : Sends reset request email and resets user's password
- checkresetkey($username, $key) : Checks the reset key based on username, returns true / false
- deleteaccount($username, $password) : Deletes the user's account. Requires current password
- addattempt($ip) : Logs a new attempt of authentication based on user IP
- getattempt($ip) : Retrieves amount of attempts from database based on user IP
- expireattempt() : Removes expired attempt logs from database, should be ran as cron job
- LogActivity($username, $action, $additionalinfo) : Logs the user's usage of the class, from login to logout. Includes attempts.
- hashpassword($password) : Hashes the password with the following : hash("SHA512", base64_encode(str_rot13(hash("SHA512", str_rot13($auth_conf['salt_1'] . $password . $auth_conf['salt_2'])))))

The extended encryption will result in a pratically uncrackable password. The session
system relies on the user's IP, if it changes, the user will have to reauthenticate.

Database layout is stored in auth.sql which you can import easily with PhpMyAdmin

Auth configuration is done in config.php where you can configure the MySQL database settings, attempts settings, email settings etc...

auth's People

Contributors

mooztik avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

auth's Issues

500 Internal Server Error

Hi, in localhost its works fine, but in ipage hosting show erros:

<title>500 Internal Server Error</title>

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, [email protected] and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

Additionally, a 500 Internal Server Error error was encountered while trying to use an ErrorDocument to handle the request.

Un saludo desde Chile

register/resetpass

Hey,

I don't know if this is obvious or not, but the in the class file, a few modifications need to be made when installing the class on a different domain. The $message_from variable should be changed, but most importantly, the domain in the verification link needs to be changed to the domain the script has been installed on. This needs to be done for the password reset function and the register function.

Just wanted to point this out, as I was a bit puzzled after clicking a verification link, I ended up on your site.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.