Laravel – Routes Signées

key, castle, security

Depuis la version 5.6, Laravel vous permet de mettre en place des URL dites signées, nous allons voir comment programmer tout cela.

Pourquoi utiliser des URL signées ?

Quelques exemples, vous souhaitez, par exemple, réaliser un sondage avec un lien unique, utilisable une seule fois, envoyé à chacun de vos utilisateurs. Ou encore, vous souhaitez confirmer une inscription à une newsletter.

Comment faire ?

Dans cet article, nous allons imaginer qu’un utilisateur a besoin de valider une information, mais que pour ce faire, il n’a pas besoin d’être connecté, mais nous devons être capables de l’identifier de manière unique et que l’information reste fiable.

Étape 1 : Utilisation du middleware "signed"

Pour Laravel < 11.x

Dans le fichier « Http/Kernel.php » ajouter le code suivant (il est possible que vous ayez déjà des middlewares inclus pour les routes).

					protected $routeMiddleware = [
 'signed' => \Illuminate\Routing\Middleware\ValidateSignature::class,
];
				

Pour Laravel >= 11.x

Ce middleware n’est plus à ajouté et il est directement intégré dans les routes (voir chapitre ci-dessous)

Étape 2 : Créer une route

Dans un fichier de gestion des routes, par exemple « route/web.php », on ajoute une route qui va prendre en compte le middleware « signed ».

					use Illuminate\Http\Request;

Route::get('newsletter/confirm/{email}/{user}', function ($email, $user) {
    if (! $request->hasValidSignature()) {
        abort(401);
    }
   // Action à ajouter
})->name('confirmation.email')->middleware(['signed']);
				

Générons aussi un moyen de créer un lien signé pour pouvoir faire des tests, le code ci-dessous est un exemple.

					use \Illuminate\Support\Facades\URL;

$url = URL::temporarySignedRoute('confirmation.email', now()->addHour(), [
    'email' => 'test@test.com',
    'user' => 1
]);
				

Étape 3 : Vérification de la route

La route est vérifiée automatiquement via la gestion des routes, si la signature n’est pas bonne, Laravel lèvera une erreur de type : Illuminate\Routing\Exceptions\InvalidSignatureException.

Comment est définie la signature ?

La signature est un hachage HMAC (sha256) de l’URL, elle utilise comme clé de chiffrement la clé secrète de l’application enregistrée dans le fichier .env de l’application.

Ongo Homes of your back office systems provides 10,000 homes for people

Overview

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Tenet has remained constant: we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Problems

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Challenge

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Solution

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Ongo Homes of your back office systems provides 10,000 homes for people

Overview

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Tenet has remained constant: we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Problems

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Challenge

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Solution

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Virtual environment in order to scale up their back office of your back office systems

Overview

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Tenet has remained constant: we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Problems

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Challenge

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Solution

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Ongo Homes of your back office systems provides 10,000 homes for people

Overview

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Tenet has remained constant: we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Problems

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Challenge

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Solution

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Virtual environment in order to scale up their back office of your back office systems

Overview

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Tenet has remained constant: we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Problems

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Challenge

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Solution

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Ongo Homes of your back office systems provides 10,000 homes for people

Overview

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Tenet has remained constant: we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Problems

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Challenge

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Solution

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Virtual environment in order to scale up their back office of your back office systems

Overview

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Tenet has remained constant: we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Problems

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Challenge

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Solution

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Ongo Homes of your back office systems provides 10,000 homes for people

Overview

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Tenet has remained constant: we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Problems

Sure, the technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Challenge

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.

Solution

Technology has come a long way since then, and the variety of the information objects we’re managing has changed a lot, but one tenet has remained constant we’ve always focused on the intersection of people, processes, and information. As the Association for Intelligent Information Management, we help organizations put their information to work.