Pages

Thursday, June 10, 2021

Debian 10 : enable unattended upgrade

 This article is a simple reminder to enable unattended upgrade feature quickly under Debian 10.

Configuration

apt install unattended-upgrades
vi /etc/apt/apt.conf.d/50unattended-upgrades

You have to activate update automatically. In that case, we made package update 
and security update :

"origin=Debian,codename=${distro_codename},label=Debian";
"origin=Debian,codename=${distro_codename},label=Debian-Security";
Unattended-Upgrade::Mail mail@toto.fr;
dpkg-reconfigure --priority=low unattended-upgrades

systemctl status unattended-upgrades.service

Note : A mail is sent every week if update occurs.

More details : https://linuxhint.com/managing_debian_unattended_upgrades/

Frequency

cat /etc/apt/apt.conf.d/20auto-upgrades

APT::Periodic::Update-Package-Lists "1";
APT::Periodic::Unattended-Upgrade "1";

You can check which packages are updated :

tail /var/log/dpkg.log


Set frequency

I didn't configure this feature but you could find more information :

https://unix.stackexchange.com/questions/342663/how-is-unattended-upgrades-started-and-how-can-i-modify-its-schedule

Tuesday, June 8, 2021

Git : How to recover your files after an improper handling ?

This small reminder permits to recover your project files very quickly without making an git clone.
For example, I use it if I delete files.

First stash your modifications :

git stash save "Bad manip"

git stash list

stash@{0}: On master: Bad manip
stash@{1}: On master: Menu publication

Then, you can delete your bad stash :

git stash drop stash@{0}

Dropped stash@{0} (838f86a5ea1ebb875f34adb1dd6fda9f1b6c89c3)

git stash list

stash@{0}: On master: Menu publication

That's all !

Feel free to comment.


GIT : version 2.17.0.windows.1

Friday, June 4, 2021

How to add CAS authentication to a PHP website ?

The main purpose of this article is to explain what you have to do in order to activate the CAS authentication. 

We will cover all steps needed to begin quickly with CAS !

My configuration :

  • Debian 9 Stretch
  • PHP 7.0
  • jasig/phpcas 1.4

Installation

You need the following Debian package :

apt-get install wget php-cli php-zip unzip

apt-get install php7.0-curl

Then, you have to install composer :

cd /root

wget -O composer-setup.php https://getcomposer.org/installer

php composer-setup.php --install-dir=/usr/local/bin --filename=composer

The next step is to add  the file composer.json with the referencies of phpcas:

{

    "require": {

        "jasig/phpcas": "^1.4"

    }

}

The composer update command retreives the phpcas library in your project (in vendor directory).So you need to execute the following :

cd /var/www/html/myproject

composer update

If you use git, don't fortget to add these lines in your .gitignore file :

vendor

composer.lock


How to use it in your PHP file ?

Here is a sample :

require __DIR__ . '/vendor/autoload.php';


// Enable debugging
phpCAS::setLogger();
// Enable verbose error messages. Disable in production!
phpCAS::setVerbose(true);
//phpCAS::setDebug("./err.log");

// initialize phpCAS
phpCAS::client(CAS_VERSION_2_0,'monserveur_cas.toto.fr',443,'/cas',FALSE);

// force CAS authentication
//phpCAS::setCasServerCACert($cas_server_ca_cert_path);
phpCAS::setNoCasServerValidation();
phpCAS::forceAuthentication();

// at this step, the user has been authenticated by the CAS server
// and the user's login name can be read with phpCAS::getUser().

if (!phpCAS::checkAuthentication()) {
die("Echec !");
}
$login = phpCAS::getUser();
print_r(phpCAS::getAttributes());
echo "===> LOGIN : $login";

PlayConsole : suppression des warnings lors de la publication (minify, symbole de debogage...)

Lors de la publication des versions dans la PlayConsole, j'avais 2 warnings pour indiquer qu'il était possible de réduire et d'o...