Added the secure logins for site.

removed htaccess in favor of a custom authentication.
Most pages are linking to the secure login screen now.
I added a minutes page to keep the meeting minutes.
Successful logins.
This commit is contained in:
Sean Joseph 2017-10-29 20:21:55 -04:00
parent b5aaafd494
commit a491c4b921
9 changed files with 160 additions and 12 deletions

59
lib/LoginController.php Normal file
View File

@ -0,0 +1,59 @@
<?php
/**
* Created by PhpStorm.
* User: sean
* Date: 10/29/17
* Time: 6:59 PM
*/
class LoginController
{
public function __construct($get, $post, $logins)
{
$this->get = $get;
$this->post = $post;
$this->logins = $logins;
if(isset($post['username'])){
$username = $post['username'];
if(array_key_exists($username,$logins)){
if(isset($post['password'])) {
$hash = hash("sha256", $post['password']);
if ($hash == $logins[$username]) {
$this->success = true;
$this->redirect = "secure/minutes.php";
}
else{
$this->redirect = "secure/index.php";
}
}
else{
$this->redirect = "secure/index.php";
}
}
else{
$this->redirect = "secure/index.php";
}
}
else{
$this->redirect = "secure/index.php";
}
}
public function getRedirect(){
return $this->redirect;
}
public function validLogin(){
return $this->success;
}
private $get; //Get data
private $post; //Post data
private $logins; //Login data
private $success = false; // successful login flag
private $redirect; //Redirect location
}

View File

@ -14,6 +14,7 @@ class View
$this->addNav("Progress", "./"); $this->addNav("Progress", "./");
$this->addNav("Meet The Team", "./about.php"); $this->addNav("Meet The Team", "./about.php");
$this->addNav("Course Site", "https://cse.msu.edu/~cse435/"); $this->addNav("Course Site", "https://cse.msu.edu/~cse435/");
$this->addNav("Secure", "./secure");
} }
public function head(){ public function head(){

13
lib/logins.inc.php Normal file
View File

@ -0,0 +1,13 @@
<?php
/**
* Created by PhpStorm.
* User: sean
* Date: 10/29/17
* Time: 7:22 PM
*/
//Login credentials for the protected pages
$logins = array(
"team6" => "1b598bb7f24d7d258a6bd2264177fb88896744e43214f86daa9f4738e5e8b5be",
"cse435" => "0f0484da86e5949eb820290270ab76e5fc63f1c4c06b0bb412cd3c551623069f",
);

11
lib/prelude.inc.php Normal file
View File

@ -0,0 +1,11 @@
<?php
/**
* Created by PhpStorm.
* User: sean
* Date: 10/29/17
* Time: 6:56 PM
*/
session_start();
define("LOGIN","login");//login session constant
define("ROOT", "/~joseph62/cse435/");

15
lib/protected.inc.php Normal file
View File

@ -0,0 +1,15 @@
<?php
/**
* Created by PhpStorm.
* User: sean
* Date: 10/29/17
* Time: 6:49 PM
*/
require_once "prelude.inc.php";
if(!$open){
if(!isset($_SESSION[LOGIN])){
header("Location: ../secure/index.php");
}
}

20
post/login.php Normal file
View File

@ -0,0 +1,20 @@
<?php
/**
* Created by PhpStorm.
* User: sean
* Date: 10/29/17
* Time: 6:59 PM
*/
require_once "../lib/prelude.inc.php";
require_once "../lib/logins.inc.php";
require_once "../lib/LoginController.php";
$controller = new LoginController($_GET,$_POST,$logins);
if($controller->validLogin()){
$_SESSION[LOGIN] = "We really out here.";
}
header("Location: " . ROOT . $controller->getRedirect());

View File

@ -1,12 +0,0 @@
AuthType Basic
AuthBasicProvider ldap
AuthName "Roaming Access"
AuthLDAPURL ldap://ds.cse.msu.edu:389/ou=People,dc=cse,dc=msu,dc=edu?uid?sub
AuthLDAPGroupAttribute memberUid
AuthLDAPGroupAttributeIsDN off
Require user cse435
Require user joseph62
Require user alphastep
Require user arentlog
Require user coppers4
Require user murra203

27
secure/index.php Normal file
View File

@ -0,0 +1,27 @@
<!DOCTYPE html>
<?php
require_once "../lib/prelude.inc.php";
?>
<html>
<head>
<meta charset="UTF-8">
<title>Secure Pages Login</title>
</head>
<body>
<h1>Secure Pages Login</h1>
<form action="../post/login.php" method="post">
<fieldset>
<legend>Login</legend>
<p>
<label for="username">Username:</label>
<input type="text" id="username" name="username" placeholder="Username">
</p>
<p>
<label for="password">Password:</label>
<input type="password" id="password" name="password" placeholder="Password">
</p>
<input type="submit" name="Submit" value="Submit">
</fieldset>
</form>
</body>
</html>

14
secure/minutes.php Normal file
View File

@ -0,0 +1,14 @@
<!DOCTYPE html>
<?php
require_once "../lib/prelude.inc.php";
require_once "../lib/protected.inc.php";
?>
<html>
<head>
<meta charset="UTF-8">
<title>Meeting Minutes</title>
</head>
<body>
<h1>Meeting Minutes</h1>
</body>
</html>