Create an account

Very important

  • To access the important data of the forums, you must be active in each forum and especially in the leaks and database leaks section, send data and after sending the data and activity, data and important content will be opened and visible for you.
  • You will only see chat messages from people who are at or below your level.
  • More than 500,000 database leaks and millions of account leaks are waiting for you, so access and view with more activity.
  • Many important data are inactive and inaccessible for you, so open them with activity. (This will be done automatically)


Thread Rating:
  • 590 Vote(s) - 3.56 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Laravel Tutorial 2: Middleware

#1
This is a continuation of the previous Laravel tutorial and will use the same project from the previous tutorial(s). If you have not been following along you may not get as much use out of this as other readers, meaning of course, user experience may vary. Also note that this is aimed at users of the 8.x Laravel software.

What is Middleware?
Middleware sits between you and the server and mitigates HTTP requests. As an example, a piece of middleware will wait for a request to the server from a user. If the user is authenticated it will direct them to their dashboard or user profile, or wherever. If the user is not authenticated it will present them with the login screen, or whatever screen you wish. Authentication isn't the only thing middlware does. Use your imagination. Logging, downloading specific files, serving specific files or folders, etc. It sits in the middle, like, a "man-in-the-middle", which you may be familiar with if you're a hacker.

make:middleware
We will use artisan (like in the previous tutorials) to create and name the middleware. Naming convention for class names states that your classes SHOULD ALWAYS start with a capital letter. Yes, because I say so, and I'm sure so does Richard Stallman (my hero) and Dennis Ritchie, the creator of the C programming language, etc., etc..


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


The command above will generate a class (PHP file) named CheckApiToken for you in the app/Http/Middleware/ folder. Now we can modify the CheckApiToken class and verify if the token that is being passed in the URL matches the one we are using to authenticate the user. I will generate an md5 hash for the words "hello world". You can do that right on the command line using the -r argument. Below will produce the md5 hash for us.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


Now we can take that hash and check it against $request->input and redirect the user accordingly.


Hidden Content
You must

[To see links please register here]

or

[To see links please register here]

to view this content.


[Image: image.png]

We want to check this for every single request into our application from the user's request, so we need to add this to the $middleware array in the Kernel.php file. This file is located at app/Http/Kernel.php. In the image below you can see that I have added it to the array.

[Image: image.png]

When you make the request to the app with the apitoken parameter in the URL you will be redirected to

[To see links please register here]

. The URL will be something like

[To see links please register here]

. You will be redirected to a page that doesn't exist if you haven't already created the access page. You can refer to the previous tutorials to add this page.

[Image: image.png]
Reply

#2
awesome share, will give a shot on this guide
Reply



Forum Jump:


Users browsing this thread:
2 Guest(s)

©0Day  2016 - 2023 | All Rights Reserved.  Made with    for the community. Connected through