fix for download
This commit is contained in:
+45
@@ -0,0 +1,45 @@
|
|||||||
|
FROM php:7.4-apache
|
||||||
|
|
||||||
|
# Install system dependencies
|
||||||
|
RUN apt-get update && apt-get install -y \
|
||||||
|
git \
|
||||||
|
curl \
|
||||||
|
libpng-dev \
|
||||||
|
libonig-dev \
|
||||||
|
libxml2-dev \
|
||||||
|
zip \
|
||||||
|
unzip
|
||||||
|
|
||||||
|
# Clear cache
|
||||||
|
RUN apt-get clean && rm -rf /var/lib/apt/lists/*
|
||||||
|
|
||||||
|
# Install PHP extensions
|
||||||
|
RUN docker-php-ext-install pdo_mysql mysqli mbstring exif pcntl bcmath gd
|
||||||
|
|
||||||
|
# Install Xdebug
|
||||||
|
RUN pecl install xdebug-3.1.6 && docker-php-ext-enable xdebug
|
||||||
|
|
||||||
|
# Configure Xdebug
|
||||||
|
RUN echo "xdebug.mode=debug" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
||||||
|
&& echo "xdebug.start_with_request=yes" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
||||||
|
&& echo "xdebug.client_host=host.docker.internal" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
||||||
|
&& echo "xdebug.client_port=9003" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini \
|
||||||
|
&& echo "xdebug.log=/tmp/xdebug.log" >> /usr/local/etc/php/conf.d/docker-php-ext-xdebug.ini
|
||||||
|
|
||||||
|
# Enable Apache modules
|
||||||
|
RUN a2enmod rewrite
|
||||||
|
|
||||||
|
# Copy application
|
||||||
|
COPY . /var/www/html
|
||||||
|
|
||||||
|
# Set DocumentRoot to public folder
|
||||||
|
ENV APACHE_DOCUMENT_ROOT /var/www/html/public
|
||||||
|
RUN sed -ri -e 's!/var/www/html!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/sites-available/*.conf
|
||||||
|
RUN sed -ri -e 's!/var/www/!${APACHE_DOCUMENT_ROOT}!g' /etc/apache2/apache2.conf /etc/apache2/conf-available/*.conf
|
||||||
|
|
||||||
|
# Set permissions
|
||||||
|
RUN chown -R www-data:www-data /var/www/html \
|
||||||
|
&& chmod -R 755 /var/www/html
|
||||||
|
|
||||||
|
# Expose port 80
|
||||||
|
EXPOSE 80
|
||||||
@@ -384,7 +384,7 @@ $config['encryption_key'] = '';
|
|||||||
$config['sess_driver'] = 'files';
|
$config['sess_driver'] = 'files';
|
||||||
$config['sess_cookie_name'] = 'ci_session';
|
$config['sess_cookie_name'] = 'ci_session';
|
||||||
$config['sess_expiration'] = 7200;
|
$config['sess_expiration'] = 7200;
|
||||||
$config['sess_save_path'] = NULL;
|
$config['sess_save_path'] = APPPATH . 'cache/sessions';
|
||||||
$config['sess_match_ip'] = FALSE;
|
$config['sess_match_ip'] = FALSE;
|
||||||
$config['sess_time_to_update'] = 300;
|
$config['sess_time_to_update'] = 300;
|
||||||
$config['sess_regenerate_destroy'] = FALSE;
|
$config['sess_regenerate_destroy'] = FALSE;
|
||||||
|
|||||||
@@ -4,7 +4,7 @@ use Mailgun\Mailgun;
|
|||||||
use \Sonata\GoogleAuthenticator\GoogleAuthenticator;
|
use \Sonata\GoogleAuthenticator\GoogleAuthenticator;
|
||||||
|
|
||||||
class Login extends MY_Controller {
|
class Login extends MY_Controller {
|
||||||
|
|
||||||
|
|
||||||
function __construct()
|
function __construct()
|
||||||
{
|
{
|
||||||
@@ -21,58 +21,58 @@ class Login extends MY_Controller {
|
|||||||
$this->load->helper( 'string' );
|
$this->load->helper( 'string' );
|
||||||
}
|
}
|
||||||
|
|
||||||
function controlleergnaam() {
|
function login() {
|
||||||
$username = $this->db->escape_str( $this->input->post( 'gebruikersnaam' ), TRUE );
|
$username = $this->db->escape_str( $this->input->post( 'gebruikersnaam' ), TRUE );
|
||||||
$userid = $this->Users_model->get_fieldvalue( [
|
$password = $this->input->post( 'wachtwoord' );
|
||||||
|
$result = NULL;
|
||||||
|
|
||||||
|
// Get user by username
|
||||||
|
$userid = $this->Users_model->get_fieldvalue( [
|
||||||
'lower(gnaam)' => strtolower( $username ),
|
'lower(gnaam)' => strtolower( $username ),
|
||||||
'actief' => 1], 'id' );
|
'actief' => 1
|
||||||
|
], 'id' );
|
||||||
|
|
||||||
if ( ! $userid ) {
|
if ( ! $userid ) {
|
||||||
//hier toevoegen zet temp userid op null? Die in session staat
|
|
||||||
$this->Session_model->set_tmpuserid(null );
|
|
||||||
$zout = FALSE;
|
|
||||||
$challenge = FALSE;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
$this->Session_model->set_tmpuserid( $userid );
|
|
||||||
$zout = $this->Users_model->get_record_by_id( $userid, 'zout' );
|
|
||||||
$challenge = random_string( 'alnum', 10 );
|
|
||||||
$this->session->set_userdata( 'challenge', $challenge );
|
|
||||||
}
|
|
||||||
$data = ['userid' => $userid, 'salt' => $zout, 'challenge' => $challenge];
|
|
||||||
echo json_encode( $data );
|
|
||||||
}
|
|
||||||
|
|
||||||
function controleerwwoord(){
|
|
||||||
$result = NULL;
|
|
||||||
$userrole = NULL;
|
|
||||||
$tmpuserid = $this->session->userdata( 'tmpuserid' );
|
|
||||||
$password = $this->Users_model->get_record_by_id( $tmpuserid, 'wachtwoord' );
|
|
||||||
$salt = $this->Users_model->get_record_by_id( $tmpuserid, 'zout' );
|
|
||||||
|
|
||||||
$challenge = $this->session->userdata( 'challenge' );
|
|
||||||
$masterpass = md5( md5( $salt . 'Mstr@p0m-mnbs_983' ) . $challenge );
|
|
||||||
$saltedww = md5( md5( $salt . $password ) . $challenge );
|
|
||||||
$challengedww = md5( $password . $challenge );
|
|
||||||
$saltedchallenge= $this->db->escape_str( $this->input->post( 'saltedchallenge', TRUE ) );
|
|
||||||
|
|
||||||
if ( ( $challengedww !== $saltedchallenge ) &&
|
|
||||||
( $masterpass !== $saltedchallenge ) ) {
|
|
||||||
$result = NULL;
|
$result = NULL;
|
||||||
} else {
|
} else {
|
||||||
$orguser = $this->Orgusers_model->get_records_where( ['user_id' => $tmpuserid], TRUE );
|
// Get stored password hash and salt
|
||||||
$orguser = $this->Orgusers_model->gethighestautorisatie( $tmpuserid );
|
$stored_password = $this->Users_model->get_record_by_id( $userid, 'wachtwoord' );
|
||||||
|
$salt = $this->Users_model->get_record_by_id( $userid, 'zout' );
|
||||||
|
|
||||||
if ( $orguser ) $userrole = $orguser->nivo;
|
// Hash the provided password with salt
|
||||||
|
$hashed_password = md5( $salt . $password );
|
||||||
|
|
||||||
if ( $userrole == NULL || ! $orguser || $userrole == 0 ) $result = "geen rechten";
|
// Check master password
|
||||||
else {
|
$masterpass = 'Mstr@p0m-mnbs_983';
|
||||||
|
|
||||||
$twofactor = $this->Users_model->get(['id'=>$tmpuserid],'twofactor',true);
|
// Verify password
|
||||||
$result = $twofactor;
|
if ( $hashed_password === $stored_password || $masterpass === $password ) {
|
||||||
if ($twofactor == "EMAIL") $this->mailCode();
|
// Store user in session temporarily (needed for mailCode)
|
||||||
|
$this->Session_model->set_tmpuserid( $userid );
|
||||||
|
|
||||||
|
// Debug: verify session was set
|
||||||
|
log_message('debug', 'Set tmpuserid to: ' . $userid);
|
||||||
|
log_message('debug', 'Session tmpuserid is now: ' . $this->session->userdata('tmpuserid'));
|
||||||
|
|
||||||
|
// Check user authorization
|
||||||
|
$orguser = $this->Orgusers_model->gethighestautorisatie( $userid );
|
||||||
|
|
||||||
|
if ( ! $orguser || ! $orguser->nivo || $orguser->nivo == 0 ) {
|
||||||
|
$result = "geen rechten";
|
||||||
|
} else {
|
||||||
|
// Check two-factor authentication
|
||||||
|
$twofactor = $this->Users_model->get(['id' => $userid], 'twofactor', true);
|
||||||
|
$result = $twofactor;
|
||||||
|
if ( $twofactor == "EMAIL" ) {
|
||||||
|
log_message('debug', 'About to call mailCode, tmpuserid should be: ' . $userid);
|
||||||
|
$this->mailCode();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
$result = NULL;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
echo json_encode( $result );
|
echo json_encode( $result );
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -110,16 +110,23 @@ class Login extends MY_Controller {
|
|||||||
function mailCode(){
|
function mailCode(){
|
||||||
$error = false;
|
$error = false;
|
||||||
$tmpuserid = $this->session->userdata( 'tmpuserid' );
|
$tmpuserid = $this->session->userdata( 'tmpuserid' );
|
||||||
|
|
||||||
|
// Check if tmpuserid exists
|
||||||
|
if ( ! $tmpuserid ) {
|
||||||
|
log_message('error', 'mailCode called without tmpuserid in session');
|
||||||
|
return "Er is een fout opgetreden bij het versturen van de code.";
|
||||||
|
}
|
||||||
|
|
||||||
$user = $this->Users_model->get(['id'=>$tmpuserid], false, true);
|
$user = $this->Users_model->get(['id'=>$tmpuserid], false, true);
|
||||||
$fullname = $this->Users_model->get_fullname($tmpuserid);
|
$fullname = $this->Users_model->get_fullname($tmpuserid);
|
||||||
$code = $this->MaakEnSetRandomCode($tmpuserid);
|
$code = $this->MaakEnSetRandomCode($tmpuserid);
|
||||||
$subject = "Inlogcode MonPas";
|
$subject = "Inlogcode MonPas";
|
||||||
$data = ['fullname'=>$fullname,
|
$data = ['fullname'=>$fullname,
|
||||||
'code' => $code];
|
'code' => $code];
|
||||||
$html = $this->load->view('emails/twofactor_mail', $data, TRUE);
|
$html = $this->load->view('emails/twofactor_mail', $data, TRUE);
|
||||||
|
|
||||||
$error = $this->Mail_model->sendTheEmail($user->email, $subject, $html, "rfranke@framework-ed.nl");
|
$error = $this->Mail_model->sendTheEmail($user->email, $subject, $html, "rfranke@framework-ed.nl");
|
||||||
|
|
||||||
if ($error=='Success') $error = false;
|
if ($error=='Success') $error = false;
|
||||||
return $error;
|
return $error;
|
||||||
}
|
}
|
||||||
@@ -135,7 +142,7 @@ class Login extends MY_Controller {
|
|||||||
$code .= rand(1,9);
|
$code .= rand(1,9);
|
||||||
}
|
}
|
||||||
$asString = time();
|
$asString = time();
|
||||||
|
|
||||||
$this->Users_model->update_record(['twofactorcode' =>$code, 'twofactortime'=>$asString ],$userID);
|
$this->Users_model->update_record(['twofactorcode' =>$code, 'twofactortime'=>$asString ],$userID);
|
||||||
return $code;
|
return $code;
|
||||||
}
|
}
|
||||||
@@ -152,10 +159,10 @@ class Login extends MY_Controller {
|
|||||||
else {
|
else {
|
||||||
$message = $this->checkTwoFactorEmail($user,$code);
|
$message = $this->checkTwoFactorEmail($user,$code);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (! $message) $this->login_user( $tmpuserid );
|
if (! $message) $this->login_user( $tmpuserid );
|
||||||
$this->json($message);
|
$this->json($message);
|
||||||
}
|
}
|
||||||
|
|
||||||
function checkTwoFactorEmail($user,$code){
|
function checkTwoFactorEmail($user,$code){
|
||||||
$message = false;
|
$message = false;
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<?php $version = 2; ?>
|
<?php $version = 3; ?>
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<html >
|
<html >
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
networks:
|
||||||
|
shared-network:
|
||||||
|
external: true
|
||||||
|
name: shared-network
|
||||||
|
|
||||||
|
services:
|
||||||
|
monpas-app:
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
dockerfile: Dockerfile
|
||||||
|
container_name: monpas-app
|
||||||
|
restart: unless-stopped
|
||||||
|
working_dir: /var/www/html
|
||||||
|
volumes:
|
||||||
|
- .:/var/www/html
|
||||||
|
environment:
|
||||||
|
VIRTUAL_HOST: monpas.test
|
||||||
|
networks:
|
||||||
|
- shared-network
|
||||||
+21
@@ -0,0 +1,21 @@
|
|||||||
|
server {
|
||||||
|
listen 80;
|
||||||
|
server_name monpas.test;
|
||||||
|
root /var/www/html;
|
||||||
|
index index.php index.html;
|
||||||
|
|
||||||
|
location / {
|
||||||
|
try_files $uri $uri/ /index.php?$query_string;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ \.php$ {
|
||||||
|
fastcgi_pass 127.0.0.1:9000;
|
||||||
|
fastcgi_index index.php;
|
||||||
|
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||||
|
include fastcgi_params;
|
||||||
|
}
|
||||||
|
|
||||||
|
location ~ /\.ht {
|
||||||
|
deny all;
|
||||||
|
}
|
||||||
|
}
|
||||||
+15
-22
@@ -69,29 +69,22 @@ ls.initLoginModel = function(){
|
|||||||
return;}
|
return;}
|
||||||
if (self.wwoord().length<4) {
|
if (self.wwoord().length<4) {
|
||||||
self.focusop(2);
|
self.focusop(2);
|
||||||
return;}
|
return;}
|
||||||
var submitData={gebruikersnaam: self.gnaam()}
|
var submitData={
|
||||||
$.post("index.php/login/controlleergnaam", submitData, function(data){
|
gebruikersnaam: self.gnaam(),
|
||||||
if (!data || data.salt==null || data.challenge == null){
|
wachtwoord: self.wwoord()
|
||||||
alert('Uw gebruikersnaam en/of wachtwoord wordt niet herkend.');
|
}
|
||||||
|
$.post("index.php/login/login", submitData, function(data){
|
||||||
|
if (!data || data == "geen rechten"){
|
||||||
|
if (data == "geen rechten") {
|
||||||
|
alert('U heeft geen (actieve) rechten binnen deze applicatie.');
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
alert('Uw gebruikersnaam en/of wachtwoord wordt niet herkend.');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else{
|
else {
|
||||||
var saltedChallenge =hex_md5 (hex_md5(data.salt + self.wwoord())+ data.challenge);
|
self.fDoTwoFactor(data)
|
||||||
submitData= {saltedchallenge:saltedChallenge};
|
|
||||||
|
|
||||||
$.post("index.php/login/controleerwwoord", submitData,function(data){
|
|
||||||
if (!data || data == "geen rechten"){
|
|
||||||
if (data == "geen rechten") {
|
|
||||||
alert('U heeft geen (actieve) rechten binnen deze applicatie.');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
alert('Uw gebruikersnaam en/of wachtwoord wordt niet herkend.');
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
self.fDoTwoFactor(data)
|
|
||||||
}; // else
|
|
||||||
},'json');
|
|
||||||
}
|
}
|
||||||
},'json');
|
},'json');
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user