Skip to content

Commit

Permalink
Version 2.1 Release
Browse files Browse the repository at this point in the history
Version 2.1 Release
  • Loading branch information
vidushigupta0607 committed Sep 22, 2022
1 parent 4f53b8b commit 3767201
Show file tree
Hide file tree
Showing 11 changed files with 383 additions and 367 deletions.
54 changes: 48 additions & 6 deletions src/adminLoginView.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,10 @@
</div>
<div class="col-md-5">
<div class="tile">
<h3 class="tile-title">Login</h3>
<h3 class="tile-title">Login with miniOrange</h3>
<form class="login_form" method="POST" action="">
<input type="hidden" name="option" value="admin_login">
<br/>
<div class="tile-body">
<div class="form-group row">
<label class="control-label col-md-3">Email</label>
Expand All @@ -39,20 +40,45 @@
<label class="control-label col-md-3">Password</label>
<div class="col-md-8">
<input class="form-control col-md-10" type="password"
name="password" id="password" placeholder="Enter a password"
minlength="6" required>
name="password" id="password" pattern="(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{8,}"
placeholder="Enter your password" minlength="8"
title="Must contain at least one number and one uppercase and lowercase letter, and at least 8 or more characters"
required>
</div>
</div>
<div class="form-group row" id="use_case_div">
<label class="control-label col-md-3">Use case <span style="color: grey">(Optional)</span></label>
<div class="col-md-8">
<textarea class="form-control col-md-10" id="use_case" name="use_case" rows="4" cols="50" placeholder="Enter your use case here..."></textarea>
</div>
</div>
<a target="_blank" href="https://login.xecurify.com/moas/idp/resetpassword"> Click here if you forgot your password?</a>
</div>
<div class="tile-footer">
<div class="row">
<div class="col-md-8 col-md-offset-3">
<button class="btn btn-primary" type="submit">
<button class="btn btn-primary" id="login" type="submit">
<i class="fa fa-fw fa-lg fa-check-circle"></i>Login
</button>
<button type="button" name="mo_saml_goback" id="goto_register" class="btn btn-primary">
<i class="fa fa-user-plus" aria-hidden="true"></i>Register
</button>
</div>
</div>
</div>
<script>
document.getElementById("goto_register").onclick = function(){
window.location.href = "register.php";
}
<?php
if(is_user_registered()){
?>
document.getElementById("goto_register").style.visibility = 'hidden';
document.getElementById("use_case_div").style.display = 'none';
<?php
}
?>
</script>
</form>
</div>
</div>
Expand All @@ -71,6 +97,7 @@
<script type="text/javascript"
src="miniorange/sso/includes/js/plugins/sweetalert.min.js"></script>
<?php
use MiniOrange\Helper\DB as setupDB;
if (isset($_SESSION['invalid_credentials']) && !empty($_SESSION['invalid_credentials'])) {
if ($_SESSION['invalid_credentials'] === true) {
echo '<script>
Expand All @@ -87,11 +114,26 @@
unset($_SESSION['invalid_credentials']);
}
}
if (isset($_SESSION['show_error_msg']) && !empty($_SESSION['show_error_msg'])) {
if ($_SESSION['show_error_msg'] === true) {
echo '<script>
$(document).ready(function(){
$.notify({
title: "ERROR: ",
message: "' . setupDB::get_option('mo_saml_message') . '",
icon: \'fa fa-times\'
},{
type: "danger"
});
});
</script>';
unset($_SESSION['show_error_msg']);
}
}
?>
</body>
</html>
<?php
use MiniOrange\Helper\DB as setupDB;
if (isset($_SESSION['show_success_msg'])) {
echo '<script>
Expand All @@ -106,7 +148,7 @@
echo '<script>
var message = document.getElementById("saml_message");
message.classList.add("error-message");
message.innerText = "' . DB::get_option('mo_saml_message') . '"
message.innerText = "' . setupDB::get_option('mo_saml_message') . '"
</script>';
unset($_SESSION['show_error_msg']);
}
Expand Down
42 changes: 34 additions & 8 deletions src/admin_login.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@
echo nl2br("$code \n $msg \n DB_CONNECTION : $env_con \n DB_DATABASE : $env_db \n DB_HOST : $env_host\n If the above configuration report is empty or incomplete, run <b>php artisan config:clear</b> in your command-line, check your <b>.env</b> file and please try again. \n\nTRACE : \n $trace");
exit;
}
if (!is_user_registered()) {
header('Location: register.php');
exit();
}

if (isset($_SESSION['authorized']) && !empty($_SESSION['authorized'])) {
if ($_SESSION['authorized'] == true) {
header('Location: licensing.php');
header('Location: setup.php');
}
}
if (isset($_REQUEST['option']) && $_REQUEST['option'] == 'admin_login') {
Expand All @@ -47,13 +43,43 @@
if (isset($user->password))
$password_check = $user->password;
else {
$_SESSION['invalid_credentials'] = true;
$_SESSION['show_error_msg'] = true;
}
if ($user != NULL) {
if (isset($user->email))
$email_check = $user->email;
else
$_SESSION['invalid_credentials'] = true;
$_SESSION['show_error_msg'] = true;
}
else if($user === NULL){
$use_case = $_POST['use_case'];
$customer = new CustomerSaml();
$content = $customer->get_customer_key();
$customerKey = json_decode($content, true);
if($customerKey != NULL){
if(strcasecmp($customerKey['status'], 'SUCCESS') == 0){
$customer->submit_register_user($email, $use_case);
DB::register_user($email, $password);
DB::update_option('mo_saml_admin_email', $email);
DB::update_option('mo_saml_admin_customer_key', $customerKey['id']);
DB::update_option('mo_saml_use_case', $use_case);
$_SESSION['authorized'] = true;
if (isset($_SESSION['authorized']) && !empty($_SESSION['authorized'])) {
if ($_SESSION['authorized'] == true) {
header('Location: setup.php');
exit;
}
}
}
}
else{
if(strcasecmp($content, 'The customer is not valid ') === 0){
DB::update_option('mo_saml_message', 'Account does not exist. Please register');
} else {
DB::update_option('mo_saml_message', $content);
}
$_SESSION['show_error_msg'] = true;
}
}

if (!empty($password_check)) {
Expand All @@ -63,7 +89,7 @@
$_SESSION['authorized'] = true;
}
$_SESSION['admin_email'] = $email;
header('Location: licensing.php');
header('Location: setup.php');
exit;
} else {
$_SESSION['invalid_credentials'] = true;
Expand Down
38 changes: 27 additions & 11 deletions src/classes/Customer.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,7 @@ function create_customer()
return $content;
}

function submit_contact_us($email, $phone, $query)
{

function send_support_email($subject, $content){
$url = 'https://login.xecurify.com/moas/api/notify/send';
$ch = curl_init($url);

Expand All @@ -65,10 +63,6 @@ function submit_contact_us($email, $phone, $query)
$customerKeyHeader = "Customer-Key: " . $customerKey;
$timestampHeader = "Timestamp: " . number_format($currentTimeInMillis, 0, '', '');
$authorizationHeader = "Authorization: " . $hashValue;
$fromEmail = $email;
$subject = "Laravel SAML free Support Query - " . $email;

$content = '<div >Hello, <br><br><b>Company :</b><a href="' . $_SERVER['SERVER_NAME'] . '" target="_blank" >' . $_SERVER['SERVER_NAME'] . '</a><br><br><b>Phone Number :</b>' . $phone . '<br><br><b>Email :<a href="mailto:' . $fromEmail . '" target="_blank">' . $fromEmail . '</a></b><br><br><b>Query: ' . $query . '</b></div>';

$support_email_id = '[email protected]';

Expand All @@ -77,7 +71,6 @@ function submit_contact_us($email, $phone, $query)
'sendEmail' => true,
'email' => array(
'customerKey' => $customerKey,
'fromEmail' => $fromEmail,
'bccEmail' => $support_email_id,
'fromName' => 'miniOrange',
'toEmail' => $support_email_id,
Expand Down Expand Up @@ -108,6 +101,26 @@ function submit_contact_us($email, $phone, $query)
}

curl_close($ch);
}
function submit_contact_us($email, $phone, $query)
{
$fromEmail = $email;
$subject = "Laravel SAML free Support Query - " . $email;

$content = '<div >Hello, <br><br><b>Company :</b><a href="' . $_SERVER['SERVER_NAME'] . '" target="_blank" >' . $_SERVER['SERVER_NAME'] . '</a><br><br><b>Phone Number :</b>' . $phone . '<br><br><b>Email :<a href="mailto:' . $fromEmail . '" target="_blank">' . $fromEmail . '</a></b><br><br><b>Query: ' . $query . '</b></div>';

$this->send_support_email($subject, $content);

return true;
}
function submit_register_user($email, $use_case)
{
$fromEmail = $email;
$subject = "Laravel SAML free Customer Registration - " . $email;

$content = '<div >Hello, <br><br><b>Company :</b><a href="' . $_SERVER['SERVER_NAME'] . '" target="_blank" >' . $_SERVER['SERVER_NAME'] . '</a><br><br><b>Email :<a href="mailto:' . $fromEmail . '" target="_blank">' . $fromEmail . '</a></b><br><br><b>Use Case: ' . $use_case . '</b></div>';

$this->send_support_email($subject, $content);

return true;
}
Expand Down Expand Up @@ -153,12 +166,15 @@ function check_customer()
function get_customer_key()
{
$url = DB::get_option('mo_saml_host_name') . "/moas/rest/customer/key";
//echo $url;exit;
$ch = curl_init($url);

$email = DB::get_option("mo_saml_admin_email");

$password = DB::get_option("mo_saml_admin_password");


if($email === '' || $email === NULL){
$email = $_POST['email'];
$password = $_POST['password'];
}
$fields = array(
'email' => $email,
'password' => $password
Expand Down
97 changes: 50 additions & 47 deletions src/classes/actions/2014_10_12_100000_create_miniorange_tables.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,54 +15,57 @@ class CreateMiniorangeTables extends Migration
*/
public function up()
{
Schema::create('mo_config', function (Blueprint $table) {
$table->string('id', 10)->unique()->nullable();
$table->text('mo_saml_host_name', 255)->nullable();
$table->text('mo_saml_admin_email', 255)->nullable();
$table->text('mo_saml_admin_password', 255)->nullable();
$table->text('mo_saml_admin_customer_key', 255)->nullable();
$table->text('mo_saml_admin_api_key', 255)->nullable();
$table->text('mo_saml_customer_token', 255)->nullable();
$table->text('mo_saml_free_version', 255)->nullable();
$table->text('mo_saml_message', 300)->nullable();
$table->text('idp_entity_id', 255)->nullable();
$table->text('saml_login_url', 255)->nullable();
$table->text('saml_login_binding_type', 255)->nullable();
$table->text('sp_base_url', 255)->nullable();
$table->text('sp_entity_id', 255)->nullable();
$table->text('acs_url', 255)->nullable();
$table->text('single_logout_url', 255)->nullable();
$table->text('saml_am_email', 255)->nullable();
$table->text('saml_am_username', 255)->nullable();
$table->text('relaystate_url', 255)->nullable();
$table->text('site_logout_url', 255)->nullable();
$table->text('saml_x509_certificate', 5000)->nullable();
$table->text('mo_saml_new_registration', 10)->nullable();
$table->text('mo_saml_admin_phone', 20)->nullable();
$table->text('mo_saml_verify_customer', 10)->nullable();
$table->text('mo_saml_idp_config_complete', 255)->nullable();
$table->text('mo_saml_transactionId', 255)->nullable();
$table->text('mo_saml_guest_enabled', 10)->nullable();
$table->text('mo_saml_registration_status', 255)->nullable();
$table->text('session_index', 255)->nullable();
});
Schema::create('mo_admin', function (Blueprint $table) {
$table->string('id', 10)->unique()->nullable();
$table->text('email', 255)->nullable();
$table->text('password', 255)->nullable();
});
$tables = [
'mo_config',
'mo_admin'
];
foreach ($tables as $table) {
DB::statement('ALTER TABLE ' . $table . ' ENGINE = InnoDB');
if(isset($_SERVER['HTTP_HOST'])){
Schema::create('mo_config', function (Blueprint $table) {
$table->string('id', 10)->unique()->nullable();
$table->text('mo_saml_host_name', 255)->nullable();
$table->text('mo_saml_admin_email', 255)->nullable();
$table->text('mo_saml_admin_password', 255)->nullable();
$table->text('mo_saml_admin_customer_key', 255)->nullable();
$table->text('mo_saml_admin_api_key', 255)->nullable();
$table->text('mo_saml_customer_token', 255)->nullable();
$table->text('mo_saml_free_version', 255)->nullable();
$table->text('mo_saml_message', 300)->nullable();
$table->text('mo_saml_use_case', 300)->nullable();
$table->text('idp_entity_id', 255)->nullable();
$table->text('saml_login_url', 255)->nullable();
$table->text('saml_login_binding_type', 255)->nullable();
$table->text('sp_base_url', 255)->nullable();
$table->text('sp_entity_id', 255)->nullable();
$table->text('acs_url', 255)->nullable();
$table->text('single_logout_url', 255)->nullable();
$table->text('saml_am_email', 255)->nullable();
$table->text('saml_am_username', 255)->nullable();
$table->text('relaystate_url', 255)->nullable();
$table->text('site_logout_url', 255)->nullable();
$table->text('saml_x509_certificate', 5000)->nullable();
$table->text('mo_saml_new_registration', 10)->nullable();
$table->text('mo_saml_admin_phone', 20)->nullable();
$table->text('mo_saml_verify_customer', 10)->nullable();
$table->text('mo_saml_idp_config_complete', 255)->nullable();
$table->text('mo_saml_transactionId', 255)->nullable();
$table->text('mo_saml_guest_enabled', 10)->nullable();
$table->text('mo_saml_registration_status', 255)->nullable();
$table->text('session_index', 255)->nullable();
});
Schema::create('mo_admin', function (Blueprint $table) {
$table->string('id', 10)->unique()->nullable();
$table->text('email', 255)->nullable();
$table->text('password', 255)->nullable();
});
$tables = [
'mo_config',
'mo_admin'
];
foreach ($tables as $table) {
DB::statement('ALTER TABLE ' . $table . ' ENGINE = InnoDB');
}
$sp_base_url = str_replace("/create_tables", "", (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
$sp_entity_id = $sp_base_url . '/miniorange_laravel_saml_connector';
$acs_url = $sp_base_url . '/sso.php';
DB::statement("INSERT INTO mo_config(id,mo_saml_host_name,mo_saml_free_version,sp_base_url,sp_entity_id,acs_url,mo_saml_new_registration) VALUES('1','https://login.xecurify.com/','".base64_encode(AESEncryption::encrypt_data('MA==', "M12K19FV"))."','".$sp_base_url."','".$sp_entity_id."','".$acs_url."','true')");
DB::insert('insert into mo_admin (id) values (1)');
}
$sp_base_url = str_replace("/create_tables", "", (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS'] === 'on' ? "https" : "http") . "://$_SERVER[HTTP_HOST]$_SERVER[REQUEST_URI]");
$sp_entity_id = $sp_base_url . '/miniorange_laravel_saml_connector';
$acs_url = $sp_base_url . '/sso.php';
DB::statement("INSERT INTO mo_config(id,mo_saml_host_name,mo_saml_free_version,sp_base_url,sp_entity_id,acs_url,mo_saml_new_registration) VALUES('1','https://login.xecurify.com/','".base64_encode(AESEncryption::encrypt_data('MA==', "M12K19FV"))."','".$sp_base_url."','".$sp_entity_id."','".$acs_url."','true')");
DB::insert('insert into mo_admin (id) values (1)');
}


Expand Down
Loading

0 comments on commit 3767201

Please sign in to comment.